{
  "name": "jevbooks — Jev ticket routing with uncertain and fallback",
  "nodes": [
    {
      "parameters": {},
      "id": "517ca245-0f9f-5397-97f1-d730a282f185",
      "name": "Manual test",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const tickets = [\n  {\n    \"id\": \"billing-1\",\n    \"subject\": \"Duplicate invoice charge\",\n    \"message\": \"I paid invoice INV-204 twice. Please refund the duplicate charge.\"\n  },\n  {\n    \"id\": \"technical-1\",\n    \"subject\": \"Upload error\",\n    \"message\": \"Every CSV upload returns error 500 since this morning. Retrying the same file fails.\"\n  },\n  {\n    \"id\": \"sales-1\",\n    \"subject\": \"Team plan\",\n    \"message\": \"We have 50 seats and need SSO. Can you explain the team plan and give us a quote?\"\n  },\n  {\n    \"id\": \"unclear-1\",\n    \"subject\": \"Help\",\n    \"message\": \"It happened again. Please fix it.\"\n  },\n  {\n    \"id\": \"other-1\",\n    \"subject\": \"Hello\",\n    \"message\": \"Just saying hello. No question today.\"\n  }\n];\nreturn tickets.map(json => ({ json }));"
      },
      "id": "3de46e77-6bfa-5714-ab9f-e18d6313aa9b",
      "name": "Sample tickets",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "operation": "route",
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "jev-1.14.0"
        },
        "stateFormat": "json",
        "stateJson": "={{ JSON.stringify({ ticket: { subject: $json.subject, message: $json.message } }) }}",
        "images": {},
        "options": {
          "simplify": false,
          "includeOtherFields": true,
          "timeout": 10000
        },
        "routeQuestionType": "noul",
        "routeInstructions": "Does `ticket` contain a concrete support request or pre-sales question?",
        "routeTrueMeans": "A request for product help, payment or invoice help, or buying the product.",
        "routeFalseMeans": "A greeting or unrelated content with no request for product help, billing, or sales.",
        "trueThreshold": 0.8,
        "falseThreshold": 0.2
      },
      "id": "de787e00-6bc5-5bbb-b4a8-ab5cc45e667b",
      "name": "Is support request",
      "type": "@typesafe-ai/n8n-nodes-typesafe-ai.typeSafeAi",
      "typeVersion": 1,
      "position": [
        460,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 1000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return $input.all().map((item, i) => ({ json: { ...item.json, support_check: { answer: item.json.route, model: item.json.model, usage: item.json.usage } }, pairedItem: { item: i } }));"
      },
      "id": "6d0fcbab-bef1-5e80-b81d-5254aa7b7459",
      "name": "Keep first decision",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        -180
      ]
    },
    {
      "parameters": {
        "operation": "route",
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "jev-1.14.0"
        },
        "stateFormat": "json",
        "stateJson": "={{ JSON.stringify({ ticket: { subject: $json.subject, message: $json.message } }) }}",
        "images": {},
        "options": {
          "simplify": false,
          "includeOtherFields": true,
          "timeout": 10000
        },
        "routeQuestionType": "choice",
        "routeInstructions": "Which team should handle the primary request in `ticket`?",
        "routes": {
          "route": [
            {
              "name": "billing",
              "description": "Payments, charges, refunds, invoices, or subscriptions already purchased."
            },
            {
              "name": "technical",
              "description": "Errors, outages, bugs, or help using an existing product."
            },
            {
              "name": "sales",
              "description": "Pre-purchase pricing, plans, product capabilities, or a request for a quote."
            }
          ]
        },
        "confidenceHandling": "separateOutput",
        "confidenceThreshold": 0.65
      },
      "id": "bff360f2-2564-5696-98d4-97566abe90a1",
      "name": "Choose team",
      "type": "@typesafe-ai/n8n-nodes-typesafe-ai.typeSafeAi",
      "typeVersion": 1,
      "position": [
        940,
        -180
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 1000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {},
      "id": "efc26335-b2b4-5c55-93ff-b0b639ea089d",
      "name": "Billing placeholder",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1220,
        -420
      ]
    },
    {
      "parameters": {},
      "id": "7c788949-0cad-588e-bca5-cc92cd1f4a45",
      "name": "Technical placeholder",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1220,
        -260
      ]
    },
    {
      "parameters": {},
      "id": "7a1e8f03-9c75-59f8-9edc-8a6bc19eb4c4",
      "name": "Sales placeholder",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1220,
        -100
      ]
    },
    {
      "parameters": {},
      "id": "0df298b0-f155-5abd-b983-973279142a13",
      "name": "Fallback human review",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1220,
        60
      ]
    },
    {
      "parameters": {},
      "id": "7b87727b-14fe-5d2c-ae8d-396417f1db2b",
      "name": "Non-support review",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        700,
        40
      ]
    },
    {
      "parameters": {},
      "id": "a956f373-ad51-5a4c-ac04-dae1542e053c",
      "name": "Uncertain ask for details",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        700,
        200
      ]
    },
    {
      "parameters": {},
      "id": "5444383f-291c-531a-9e47-a57b8f269400",
      "name": "API error review",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        940,
        380
      ]
    }
  ],
  "connections": {
    "Manual test": {
      "main": [
        [
          {
            "node": "Sample tickets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample tickets": {
      "main": [
        [
          {
            "node": "Is support request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is support request": {
      "main": [
        [
          {
            "node": "Keep first decision",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Non-support review",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Uncertain ask for details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "API error review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep first decision": {
      "main": [
        [
          {
            "node": "Choose team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Choose team": {
      "main": [
        [
          {
            "node": "Billing placeholder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Technical placeholder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sales placeholder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fallback human review",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "API error review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}
