{ "name": "[n8n Template] Claude AI LINE Chatbot", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "claude-line-bot", "responseMode": "responseNode", "options": {} }, "id": "a1b2c3d4-0001-0001-0001-a1b2c3d40001", "name": "LINE Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [200, 300], "webhookId": "claude-line-bot" }, { "parameters": { "jsCode": "// Validate LINE signature and extract message\nconst body = $input.first().json;\nconst events = body.events || [];\n\nconst textEvent = events.find(\n e => e.type === 'message' && e.message?.type === 'text'\n);\n\nif (!textEvent) {\n // Non-text event (sticker, image, etc.) — skip\n return [];\n}\n\nreturn [{\n json: {\n userId: textEvent.source.userId,\n replyToken: textEvent.replyToken,\n userMessage: textEvent.message.text\n }\n}];" }, "id": "a1b2c3d4-0002-0002-0002-a1b2c3d40002", "name": "Extract Message", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [420, 300] }, { "parameters": { "method": "POST", "url": "https://api.anthropic.com/v1/messages", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "x-api-key", "value": "={{ $env.ANTHROPIC_API_KEY }}" }, { "name": "anthropic-version", "value": "2023-06-01" }, { "name": "content-type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"model\": \"claude-opus-4-5\",\n \"max_tokens\": 500,\n \"system\": \"You are a helpful assistant. Reply concisely in the same language the user writes in.\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"{{ $json.userMessage }}\"\n }\n ]\n}", "options": {} }, "id": "a1b2c3d4-0003-0003-0003-a1b2c3d40003", "name": "Ask Claude", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4, "position": [640, 300] }, { "parameters": { "method": "POST", "url": "https://api.line.me/v2/bot/message/reply", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Authorization", "value": "=Bearer {{ $env.LINE_CHANNEL_ACCESS_TOKEN }}" }, { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"replyToken\": \"{{ $('Extract Message').first().json.replyToken }}\",\n \"messages\": [\n {\n \"type\": \"text\",\n \"text\": \"{{ $json.content[0].text }}\"\n }\n ]\n}", "options": {} }, "id": "a1b2c3d4-0004-0004-0004-a1b2c3d40004", "name": "Reply via LINE", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4, "position": [860, 300] }, { "parameters": { "respondWith": "text", "responseBody": "OK", "options": {} }, "id": "a1b2c3d4-0005-0005-0005-a1b2c3d40005", "name": "Return 200", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1, "position": [420, 480] } ], "connections": { "LINE Webhook": { "main": [ [ { "node": "Extract Message", "type": "main", "index": 0 }, { "node": "Return 200", "type": "main", "index": 0 } ] ] }, "Extract Message": { "main": [ [ { "node": "Ask Claude", "type": "main", "index": 0 } ] ] }, "Ask Claude": { "main": [ [ { "node": "Reply via LINE", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1" }, "versionId": "n8n-claude-template-01", "meta": { "templateCredsSetupCompleted": false, "instanceId": "template" }, "pinData": {}, "staticData": null }