{
  "name": "Jev · routage de tickets avec seuil de confiance",
  "nodes": [
    {
      "id": "n1",
      "name": "Note n1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -80,
        -380
      ],
      "parameters": {
        "content": "## 1. Identifiant\nCréez un identifiant **Header Auth** :\n- Name : `Authorization`\n- Value : `Bearer VOTRE_CLE_JEV`\n\nSélectionnez-le dans le nœud **Jev : service et urgence**.",
        "width": 380,
        "height": 260
      }
    },
    {
      "id": "n2",
      "name": "Note n2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        320,
        -380
      ],
      "parameters": {
        "content": "## 2. Avant la production\n- Calibrez le seuil sur vos tickets, dans votre langue.\n- Commencez en mode shadow : journalisez sans agir.\n- Pseudonymisez les données personnelles avant l'envoi : Jev est hébergé aux États-Unis.\n\nGuide complet : https://jevmigration.com/blog/jev-n8n/",
        "width": 380,
        "height": 260
      }
    },
    {
      "id": "trigger",
      "name": "Tester le workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "input",
      "name": "Ticket et réglages",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "input-0",
              "name": "ticket",
              "value": "Bonjour, ma facture de septembre apparaît deux fois sur mon relevé. Pouvez-vous rembourser le doublon ?",
              "type": "string"
            },
            {
              "id": "input-1",
              "name": "seuil",
              "value": 0.6,
              "type": "number"
            },
            {
              "id": "input-2",
              "name": "modele",
              "value": "jev-1.13.0",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "jev",
      "name": "Jev : service et urgence",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 1000,
      "onError": "continueErrorOutput",
      "parameters": {
        "method": "POST",
        "url": "https://api.typesafe.ai/v1/systemone",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"state\": {{ JSON.stringify($json.ticket) }},\n  \"model\": \"{{ $json.modele }}\",\n  \"questions\": {\n    \"service\": {\n      \"type\": \"choice\",\n      \"instructions\": \"Quel service doit traiter ce ticket ?\",\n      \"criteria\": {\n        \"facturation\": \"Paiements, factures, remboursements\",\n        \"technique\": \"Bugs, pannes, intégrations\",\n        \"commercial\": \"Tarifs, devis, nouveaux comptes\"\n      }\n    },\n    \"urgent\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Le message exprime-t-il une urgence ?\"\n    }\n  }\n}",
        "options": {
          "timeout": 5000
        }
      }
    },
    {
      "id": "log",
      "name": "Journal de décision",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        680,
        -100
      ],
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "log-0",
              "name": "version_modele",
              "value": "={{ $json.model }}",
              "type": "string"
            },
            {
              "id": "log-1",
              "name": "service",
              "value": "={{ $json.answers.service.choice }}",
              "type": "string"
            },
            {
              "id": "log-2",
              "name": "confiance",
              "value": "={{ $json.answers.service.confidence }}",
              "type": "number"
            },
            {
              "id": "log-3",
              "name": "probabilites",
              "value": "={{ $json.answers.service.probabilities }}",
              "type": "object"
            },
            {
              "id": "log-4",
              "name": "urgence",
              "value": "={{ $json.answers.urgent.noul }}",
              "type": "number"
            },
            {
              "id": "log-5",
              "name": "seuil",
              "value": "={{ $('Ticket et réglages').item.json.seuil }}",
              "type": "number"
            },
            {
              "id": "log-6",
              "name": "decide_par",
              "value": "={{ $json.answers.service.confidence >= $('Ticket et réglages').item.json.seuil ? 'jev' : 'llm' }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "gate",
      "name": "Jev assez sûr ?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        -100
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "gate-0",
              "leftValue": "={{ $json.decide_par }}",
              "rightValue": "jev",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "route",
      "name": "Router par service",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1120,
        -200
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "route-0",
                    "leftValue": "={{ $json.service }}",
                    "rightValue": "facturation",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Facturation"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "route-1",
                    "leftValue": "={{ $json.service }}",
                    "rightValue": "technique",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Technique"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "route-2",
                    "leftValue": "={{ $json.service }}",
                    "rightValue": "commercial",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Commercial"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "out-0",
      "name": "Facturation",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1360,
        -320
      ],
      "parameters": {}
    },
    {
      "id": "out-1",
      "name": "Technique",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1360,
        -200
      ],
      "parameters": {}
    },
    {
      "id": "out-2",
      "name": "Commercial",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1360,
        -80
      ],
      "parameters": {}
    },
    {
      "id": "fallback",
      "name": "Repli : votre LLM actuel",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1120,
        120
      ],
      "parameters": {}
    }
  ],
  "connections": {
    "Tester le workflow": {
      "main": [
        [
          {
            "node": "Ticket et réglages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ticket et réglages": {
      "main": [
        [
          {
            "node": "Jev : service et urgence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Jev : service et urgence": {
      "main": [
        [
          {
            "node": "Journal de décision",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Repli : votre LLM actuel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Journal de décision": {
      "main": [
        [
          {
            "node": "Jev assez sûr ?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Jev assez sûr ?": {
      "main": [
        [
          {
            "node": "Router par service",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Repli : votre LLM actuel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Router par service": {
      "main": [
        [
          {
            "node": "Facturation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Technique",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Commercial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}
