{
  "name": "Support Ticket Classifier",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "classify-ticket",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "stc0001-0001-4000-8000-000000000001",
      "name": "Receive Ticket Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list"
        },
        "messages": {
          "values": [
            {
              "content": "Classify this support ticket into one of these categories: billing, technical, account, feature-request, bug-report, or general.\nAlso assign a priority: urgent, high, medium, or low.\nRespond with JSON only in this format: {\"category\": \"...\", \"priority\": \"...\", \"summary\": \"one sentence summary\"}\n\nTicket Subject: {{ $json.body.subject }}\nTicket Body: {{ $json.body.body }}"
            }
          ]
        },
        "options": {
          "temperature": 0,
          "responseFormat": "json_object"
        }
      },
      "id": "stc0001-0002-4000-8000-000000000002",
      "name": "Classify with AI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [460, 300]
    },
    {
      "parameters": {
        "jsCode": "const aiResponse = JSON.parse($input.item.json.message.content);\nconst ticketData = $('Receive Ticket Webhook').item.json.body;\nreturn [{\n  json: {\n    ticketId: ticketData.ticketId || 'unknown',\n    subject: ticketData.subject,\n    category: aiResponse.category,\n    priority: aiResponse.priority,\n    summary: aiResponse.summary,\n    assignedTeam: {\n      billing: 'finance-team',\n      technical: 'engineering-team',\n      account: 'account-team',\n      'feature-request': 'product-team',\n      'bug-report': 'engineering-team',\n      general: 'support-team'\n    }[aiResponse.category] || 'support-team'\n  }\n}];"
      },
      "id": "stc0001-0003-4000-8000-000000000003",
      "name": "Parse and Route",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false },
          "conditions": [
            {
              "leftValue": "={{ $json.priority }}",
              "rightValue": "urgent",
              "operator": { "type": "string", "operation": "equals" }
            }
          ]
        }
      },
      "id": "stc0001-0004-4000-8000-000000000004",
      "name": "Is Urgent",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "status",
              "value": "escalated",
              "type": "string"
            },
            {
              "name": "notification",
              "value": "URGENT: Ticket {{ $json.ticketId }} requires immediate attention.",
              "type": "string"
            }
          ]
        }
      },
      "id": "stc0001-0005-4000-8000-000000000005",
      "name": "Mark Escalated",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [1120, 180]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "status",
              "value": "queued",
              "type": "string"
            },
            {
              "name": "notification",
              "value": "Ticket {{ $json.ticketId }} queued for {{ $json.assignedTeam }}.",
              "type": "string"
            }
          ]
        }
      },
      "id": "stc0001-0006-4000-8000-000000000006",
      "name": "Queue for Team",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [1120, 420]
    }
  ],
  "connections": {
    "Receive Ticket Webhook": {
      "main": [[{ "node": "Classify with AI", "type": "main", "index": 0 }]]
    },
    "Classify with AI": {
      "main": [[{ "node": "Parse and Route", "type": "main", "index": 0 }]]
    },
    "Parse and Route": {
      "main": [[{ "node": "Is Urgent", "type": "main", "index": 0 }]]
    },
    "Is Urgent": {
      "main": [
        [{ "node": "Mark Escalated", "type": "main", "index": 0 }],
        [{ "node": "Queue for Team", "type": "main", "index": 0 }]
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
