{
  "name": "Shopping App Action Classifier - Ollama",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        -80,
        300
      ],
      "id": "chat-1",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "Classify the customer message into exactly one action: product_search, order_track, support_ticket, or hang_to_human. Detect the primary language as Eng or Th. Return only the structured result."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        260,
        300
      ],
      "id": "llm-1",
      "name": "Classify Customer Message"
    },
    {
      "parameters": {
        "model": "qwen3:8b",
        "options": {
          "temperature": 0,
          "keepAlive": "30m"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "typeVersion": 1,
      "position": [
        180,
        520
      ],
      "id": "model-1",
      "name": "Ollama Chat Model"
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"action\": { \"type\": \"string\", \"enum\": [\"product_search\", \"order_track\", \"support_ticket\", \"hang_to_human\"] },\n    \"language\": { \"type\": \"string\", \"enum\": [\"Eng\", \"Th\"] }\n  },\n  \"required\": [\"action\", \"language\"],\n  \"additionalProperties\": false\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        480,
        520
      ],
      "id": "parser-1",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={{ $json.output }}",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        600,
        300
      ],
      "id": "set-1",
      "name": "Extract Pure JSON"
    },
    {
      "parameters": {
        "mode": "expression",
        "output": "={{ ['product_search','order_track','support_ticket','hang_to_human'].indexOf($json.action) }}",
        "looseTypeValidation": true
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        860,
        300
      ],
      "id": "switch-1",
      "name": "Route by Action"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1160,
        60
      ],
      "id": "noop-1",
      "name": "PRODUCT SEARCH - Replace with Product Tool"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1160,
        220
      ],
      "id": "noop-2",
      "name": "ORDER TRACK - Replace with Order Tool"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1160,
        380
      ],
      "id": "noop-3",
      "name": "SUPPORT TICKET - Replace with Ticket Tool"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1160,
        540
      ],
      "id": "noop-4",
      "name": "HANG TO HUMAN - Replace with Human Handoff"
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Classify Customer Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Customer Message": {
      "main": [
        [
          {
            "node": "Extract Pure JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Classify Customer Message",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Classify Customer Message",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Extract Pure JSON": {
      "main": [
        [
          {
            "node": "Route by Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Action": {
      "main": [
        [
          {
            "node": "PRODUCT SEARCH - Replace with Product Tool",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ORDER TRACK - Replace with Order Tool",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SUPPORT TICKET - Replace with Ticket Tool",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HANG TO HUMAN - Replace with Human Handoff",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}