{
  "name": "Starter - Customer ticket routing",
  "nodes": [
    {
      "parameters": {
        "content": "# Ticket routing starter\n\nUse this workflow to understand how support messages can be classified before they enter a ticket queue.\n\nReplace the placeholder nodes with Zendesk, Intercom, Jira, Slack, Gmail, or your internal ticket API.",
        "height": 250,
        "width": 420
      },
      "id": "ticket-note-2026",
      "name": "Read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -760,
        -180
      ]
    },
    {
      "parameters": {},
      "id": "ticket-manual-trigger-2026",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -760,
        160
      ]
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      ticket_id: 'T-1001',\n      customer_email: 'customer@example.com',\n      subject: '付款後帳號仍無法升級',\n      message: '我已經付款，但系統仍顯示免費方案。請協助確認帳號和發票。',\n      source: 'support_form',\n      received_at: new Date().toISOString()\n    }\n  }\n];"
      },
      "id": "ticket-sample-data-2026",
      "name": "Sample ticket data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -520,
        160
      ]
    },
    {
      "parameters": {
        "jsCode": "const categoryRules = [\n  { category: 'billing', owner: 'finance_support', keywords: ['付款', '發票', '收據', '退款', '方案', 'billing', 'invoice'] },\n  { category: 'account', owner: 'account_support', keywords: ['登入', '帳號', '密碼', '驗證', 'login', 'account'] },\n  { category: 'bug', owner: 'engineering_support', keywords: ['錯誤', 'bug', '無法', '失敗', 'error', 'broken'] },\n  { category: 'feature_request', owner: 'product_team', keywords: ['希望', '功能', '建議', 'request', 'feature'] }\n];\n\nreturn items.map((item) => {\n  const ticket = item.json;\n  const text = `${ticket.subject || ''} ${ticket.message || ''}`.toLowerCase();\n  const matched = categoryRules.find((rule) => rule.keywords.some((keyword) => text.includes(keyword.toLowerCase())));\n  const category = matched?.category || 'general';\n  const owner = matched?.owner || 'support_triage';\n  const priority = /無法|失敗|付款|billing|error/i.test(text) ? 'high' : 'normal';\n\n  return {\n    json: {\n      ...ticket,\n      category,\n      owner,\n      priority,\n      next_action: `Send to ${owner}, priority ${priority}`\n    }\n  };\n});"
      },
      "id": "ticket-classify-2026",
      "name": "Classify ticket",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -260,
        160
      ]
    },
    {
      "parameters": {},
      "id": "ticket-system-placeholder-2026",
      "name": "Replace with ticket system",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        20,
        160
      ]
    },
    {
      "parameters": {},
      "id": "ticket-notify-placeholder-2026",
      "name": "Replace with team notification",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        280,
        160
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Sample ticket data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample ticket data": {
      "main": [
        [
          {
            "node": "Classify ticket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify ticket": {
      "main": [
        [
          {
            "node": "Replace with ticket system",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace with ticket system": {
      "main": [
        [
          {
            "node": "Replace with team notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "tags": []
}
