AutomationFlowsAI & RAG › A - Line Incoming (notion)

A - Line Incoming (notion)

A - LINE Incoming (Notion). Uses httpRequest, agent, lmChatOpenAi. Webhook trigger; 20 nodes.

Webhook trigger★★★★☆ complexityAI-powered20 nodesHTTP RequestAgentOpenAI Chat
AI & RAG Trigger: Webhook Nodes: 20 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "A - LINE Incoming (Notion)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "line-incoming",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1500,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "auth-1",
              "leftValue": "={{ $json.headers['x-internal-token'] }}",
              "rightValue": "={{ $env.INTERNAL_N8N_TOKEN }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "if-auth",
      "name": "IF: X-Internal-Token",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1280,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseCode": 401,
        "responseBody": "unauthorized",
        "options": {}
      },
      "id": "respond-401",
      "name": "Respond 401",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        -1060,
        200
      ]
    },
    {
      "parameters": {
        "url": "=https://api.notion.com/v1/data_sources/{{ $env.NOTION_EVENT_LOG_DATA_SOURCE_ID }}/query",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Notion-Version",
              "value": "={{ $env.NOTION_VERSION || '2025-09-03' }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"filter\": {\n    \"property\": \"Event ID\",\n    \"title\": { \"equals\": \"{{ $('Webhook').first().json.body.webhook_event_id }}\" }\n  },\n  \"page_size\": 1\n}",
        "options": {}
      },
      "id": "query-eventlog",
      "name": "Notion: Query EventLog (idempotency)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1060,
        -200
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "dup-1",
              "leftValue": "={{ $json.results.length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "if-duplicate",
      "name": "IF: duplicate?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -840,
        -200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseCode": 200,
        "responseBody": "={ \"ok\": true, \"deduped\": true }",
        "options": {}
      },
      "id": "respond-dedup",
      "name": "Respond 200 (deduped)",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        -620,
        -300
      ]
    },
    {
      "parameters": {
        "url": "https://api.notion.com/v1/pages",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Notion-Version",
              "value": "={{ $env.NOTION_VERSION || '2025-09-03' }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"parent\": { \"type\": \"data_source_id\", \"data_source_id\": \"{{ $env.NOTION_EVENT_LOG_DATA_SOURCE_ID }}\" },\n  \"properties\": {\n    \"Event ID\": { \"title\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $('Webhook').first().json.body.webhook_event_id }}\" } }] },\n    \"Received At\": { \"date\": { \"start\": \"{{ $now.toISO() }}\" } },\n    \"Line User ID\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $('Webhook').first().json.body.line_user_id }}\" } }] },\n    \"Message Text\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": {{ JSON.stringify(($('Webhook').first().json.body.message_text || '').slice(0, 1900)) }} } }] },\n    \"Processed\": { \"checkbox\": false }\n  }\n}",
        "options": {}
      },
      "id": "create-eventlog",
      "name": "Notion: Create EventLog page",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -620,
        -100
      ]
    },
    {
      "parameters": {
        "url": "=https://api.notion.com/v1/data_sources/{{ $env.NOTION_CUSTOMER_SESSIONS_DATA_SOURCE_ID }}/query",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Notion-Version",
              "value": "={{ $env.NOTION_VERSION || '2025-09-03' }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"filter\": {\n    \"property\": \"Line User ID\",\n    \"rich_text\": { \"equals\": \"{{ $('Webhook').first().json.body.line_user_id }}\" }\n  },\n  \"page_size\": 1\n}",
        "options": {}
      },
      "id": "query-session",
      "name": "Notion: Query CustomerSession",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -400,
        -100
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=\u5ba2\u4eba\u8a0a\u606f\uff1a{{ $('Webhook').first().json.body.message_text }}\n\n\u4e4b\u524d\u5df2\u77e5\u6b04\u4f4d (slots_json)\uff1a{{ ($json.results[0]?.properties?.['Slots JSON']?.rich_text?.[0]?.plain_text) || '{}' }}\n\n\u76ee\u524d\u6642\u9593\uff08Asia/Taipei\uff09\uff1a{{ $now.setZone('Asia/Taipei').toFormat('yyyy-MM-dd HH:mm') }}",
        "options": {
          "systemMessage": "\u4f60\u662f\u51b7\u6c23\u88dd\u4fee / \u7dad\u4fee\u516c\u53f8\u7684 LINE \u9810\u7d04\u5ba2\u670d AI\u3002\n\u4f60\u7684\u4efb\u52d9\u662f\u5354\u52a9\u5ba2\u4eba\u5b8c\u6210\u9810\u7d04\u3001\u6539\u671f\u3001\u53d6\u6d88\u3001\u67e5\u8a62\u670d\u52d9\u5167\u5bb9\u3002\n\u4f60\u53ea\u8ca0\u8cac\u300c\u5c0d\u8a71\u300d\u8207\u300c\u6c7a\u5b9a\u4e0b\u4e00\u6b65 action\u300d\u3002\u5be6\u969b\u6392\u7a0b\u67e5\u8a62\u3001\u5efa\u7acb\u3001\u66f4\u65b0\u90fd\u7531 n8n \u7684 deterministic nodes \u57f7\u884c\u3002\n\n\u4f60\u4e0d\u80fd\u4e82\u627f\u8afe\u50f9\u683c\u3002\n\u4f60\u4e0d\u80fd\u627f\u8afe\u4e0d\u5b58\u5728\u7684\u6642\u6bb5\u3002\n\u4f60\u4e0d\u80fd\u81ea\u884c\u5beb\u5165\u6392\u7a0b\u3002\n\u4f60\u53ea\u80fd\u8f38\u51fa action\uff0c\u7531 n8n \u63a5\u624b\u57f7\u884c\u3002\n\n\u670d\u52d9\u9805\u76ee\uff1a\n- \u51b7\u6c23\u5b89\u88dd\n- \u51b7\u6c23\u7dad\u4fee\n- \u51b7\u6c23\u6e05\u6d17\n- \u51b7\u6c23\u79fb\u6a5f\n- \u73fe\u5834\u4f30\u50f9\n\n\u5fc5\u9808\u6536\u96c6\u7684\u6b04\u4f4d\uff08\u7f3a\u4e00\u4e0d\u53ef\uff09\uff1acustomer_name / phone / address / district / service_type / issue_description / ac_count / preferred_date / preferred_time_range\n\n\u898f\u5247\uff1a\n- \u5ba2\u4eba\u8cc7\u6599\u4e0d\u8db3\u6642\uff0c\u53ea\u88dc\u554f\u6700\u5c11\u5fc5\u8981\u6b04\u4f4d\uff0c\u4e00\u6b21\u6700\u591a\u554f 2~3 \u9805\u3002\n- \u5ba2\u4eba\u8981\u9810\u7d04\u6642\uff0c\u5fc5\u9808\u5148\u6aa2\u67e5\u53ef\u9810\u7d04\u6642\u6bb5\uff0c\u4e0d\u53ef\u76f4\u63a5\u8aaa\u9810\u7d04\u6210\u529f\u3002\n- \u53ea\u6709\u7576\u5ba2\u4eba\u300c\u660e\u78ba\u78ba\u8a8d\u300d\u67d0\u500b\u6642\u6bb5\u5f8c\uff08\u4f8b\u5982\u300c\u5c31 5/3 13:00-15:00\u300d\u3001\u300cOK\u300d\u3001\u300c\u597d\u300d\u3001\u300c\u78ba\u5b9a\u300d\uff09\uff0c\u624d\u8f38\u51fa action.type = CREATE_BOOKING\uff0c\u4e14 confirmed_by_customer = true\u3002\n- \u4e0d\u80fd\u4fdd\u8b49\u56fa\u5b9a\u50f9\u683c\uff0c\u53ea\u80fd\u8aaa\u300c\u5be6\u969b\u8cbb\u7528\u9700\u4f9d\u73fe\u5834\u72c0\u6cc1\u6216\u5e2b\u5085\u78ba\u8a8d\u300d\u3002\n- \u6d89\u53ca\u5371\u96aa\u60c5\u6cc1\uff08\u71d2\u7126\u5473\u3001\u5192\u7159\u3001\u6f0f\u96fb\u3001\u8df3\u96fb\uff09\uff0c\u5fc5\u9808\u5148\u5efa\u8b70\u5ba2\u4eba\u300c\u8acb\u5148\u95dc\u9589\u7e3d\u96fb\u6e90\u300d\uff0c\u4e26\u628a action.type \u8a2d\u70ba ESCALATE_HUMAN\u3002\n- \u56de\u8986\u8a9e\u6c23\u89aa\u5207\u3001\u7c21\u77ed\u3001\u6e05\u695a\u3001\u6709\u79ae\u8c8c\u3002\u4e0d\u4f7f\u7528 emoji\u3002\n\nNotion storage \u898f\u5247\uff1aStatus \u7528 Pending/Confirmed/Assigned/Done/Cancelled\uff1bService Type \u7528\u4e0a\u9762 5 \u7a2e\u3002\n\n\u8f38\u51fa\u683c\u5f0f\uff08\u5f37\u5236\uff09\uff1a\n- \u5fc5\u9808\u662f\u5408\u6cd5 JSON\u3002\n- \u4e0d\u8981\u8f38\u51fa Markdown\u3002\n- \u4e0d\u8981\u8f38\u51fa JSON \u4ee5\u5916\u7684\u4efb\u4f55\u6587\u5b57\u3002\n\n\u8f38\u51fa schema\uff1a\n{\n  \"intent\": \"book | reschedule | cancel | pricing | faq | complaint | emergency | human\",\n  \"confidence\": 0.0,\n  \"known_fields\": {\n    \"customer_name\": \"\", \"phone\": \"\", \"address\": \"\", \"district\": \"\",\n    \"service_type\": \"\", \"issue_description\": \"\", \"ac_count\": \"\",\n    \"preferred_date\": \"\", \"preferred_time_range\": \"\"\n  },\n  \"missing_fields\": [],\n  \"customer_reply\": \"\u8981\u986f\u793a\u7d66\u5ba2\u4eba\u7684\u56de\u8986\u8a0a\u606f\uff08\u7d14\u6587\u5b57\u3001\u7c21\u6f54\uff09\",\n  \"action\": {\n    \"type\": \"ASK_MORE | ANSWER_FAQ | CHECK_AVAILABILITY | CREATE_BOOKING | CANCEL_BOOKING | RESCHEDULE_BOOKING | ESCALATE_HUMAN\",\n    \"requires_confirmation\": true,\n    \"confirmed_by_customer\": false\n  },\n  \"internal_note\": \"\"\n}"
        }
      },
      "id": "ai-agent",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -180,
        -100
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {
          "temperature": 0.2,
          "responseFormat": "json_object"
        }
      },
      "id": "openai-model",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -220,
        100
      ]
    },
    {
      "parameters": {
        "jsCode": "// Parse AI Agent JSON output. The Agent returns either text or already-parsed JSON.\nconst raw = $input.first().json.output ?? $input.first().json.text ?? $input.first().json;\nlet parsed;\nif (typeof raw === 'string') {\n  try { parsed = JSON.parse(raw); } catch (e) { parsed = { error: 'parse_failed', raw }; }\n} else {\n  parsed = raw;\n}\nreturn [{ json: { ai: parsed, webhook: $('Webhook').first().json.body } }];"
      },
      "id": "parse-ai",
      "name": "Parse AI Output",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        60,
        -100
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "ASK_MORE",
                    "leftValue": "={{ $json.ai.action.type }}",
                    "rightValue": "ASK_MORE",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "ASK_MORE"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "ANSWER_FAQ",
                    "leftValue": "={{ $json.ai.action.type }}",
                    "rightValue": "ANSWER_FAQ",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "ANSWER_FAQ"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "CHECK_AVAILABILITY",
                    "leftValue": "={{ $json.ai.action.type }}",
                    "rightValue": "CHECK_AVAILABILITY",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "CHECK_AVAILABILITY"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "CREATE_BOOKING",
                    "leftValue": "={{ $json.ai.action.type }}",
                    "rightValue": "CREATE_BOOKING",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "CREATE_BOOKING"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "id": "ESCALATE_HUMAN",
                    "leftValue": "={{ $json.ai.action.type }}",
                    "rightValue": "ESCALATE_HUMAN",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "ESCALATE_HUMAN"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "switch-action",
      "name": "Switch by action.type",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        280,
        -100
      ]
    },
    {
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendHeaders": false,
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\": \"{{ $('Webhook').first().json.body.reply_token }}\",\n  \"messages\": [\n    { \"type\": \"text\", \"text\": {{ JSON.stringify($json.ai.customer_reply) }} }\n  ]\n}",
        "options": {}
      },
      "id": "line-reply-ask",
      "name": "LINE Reply (ASK_MORE)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        -300
      ]
    },
    {
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendHeaders": false,
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\": \"{{ $('Webhook').first().json.body.reply_token }}\",\n  \"messages\": [\n    { \"type\": \"text\", \"text\": {{ JSON.stringify($json.ai.customer_reply) }} }\n  ]\n}",
        "options": {}
      },
      "id": "line-reply-faq",
      "name": "LINE Reply (FAQ)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        -150
      ]
    },
    {
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendHeaders": false,
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\": \"{{ $('Webhook').first().json.body.reply_token }}\",\n  \"messages\": [\n    { \"type\": \"text\", \"text\": {{ JSON.stringify($json.ai.customer_reply) }} }\n  ]\n}",
        "options": {}
      },
      "id": "line-reply-availability",
      "name": "LINE Reply (CHECK_AVAILABILITY)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://api.notion.com/v1/pages",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Notion-Version",
              "value": "={{ $env.NOTION_VERSION || '2025-09-03' }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"parent\": { \"type\": \"data_source_id\", \"data_source_id\": \"{{ $env.NOTION_BOOKINGS_DATA_SOURCE_ID }}\" },\n  \"properties\": {\n    \"Booking\": { \"title\": [{ \"type\": \"text\", \"text\": { \"content\": \"BK-{{ $now.toFormat('yyyyMMdd-HHmmss') }}\" } }] },\n    \"Booking ID\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"BK-{{ $now.toFormat('yyyyMMdd-HHmmss') }}\" } }] },\n    \"Status\": { \"select\": { \"name\": \"Pending\" } },\n    \"Customer Name\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $json.ai.known_fields.customer_name }}\" } }] },\n    \"Phone\": { \"phone_number\": \"{{ $json.ai.known_fields.phone }}\" },\n    \"Address\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $json.ai.known_fields.address }}\" } }] },\n    \"District\": { \"select\": { \"name\": \"{{ $json.ai.known_fields.district }}\" } },\n    \"Service Type\": { \"select\": { \"name\": \"{{ $json.ai.known_fields.service_type }}\" } },\n    \"Issue Description\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $json.ai.known_fields.issue_description }}\" } }] },\n    \"AC Count\": { \"number\": {{ Number($json.ai.known_fields.ac_count) || 1 }} },\n    \"Customer Line User ID\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $('Webhook').first().json.body.line_user_id }}\" } }] },\n    \"Source\": { \"select\": { \"name\": \"LINE\" } },\n    \"Last Webhook Event ID\": { \"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"{{ $('Webhook').first().json.body.webhook_event_id }}\" } }] }\n  }\n}",
        "options": {}
      },
      "id": "create-booking",
      "name": "Notion: Create Booking",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        150
      ]
    },
    {
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\": \"{{ $('Webhook').first().json.body.reply_token }}\",\n  \"messages\": [\n    { \"type\": \"text\", \"text\": {{ JSON.stringify($('Parse AI Output').first().json.ai.customer_reply) }} }\n  ]\n}",
        "options": {}
      },
      "id": "line-reply-create",
      "name": "LINE Reply (CREATE_BOOKING)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        840,
        150
      ]
    },
    {
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/push",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"to\": \"{{ $env.ADMIN_LINE_TO }}\",\n  \"messages\": [\n    { \"type\": \"text\", \"text\": {{ JSON.stringify(($('Parse AI Output').first().json.ai.customer_reply || '\u5ba2\u4eba\u8f49\u4eba\u5de5') + '\\n\\n[ESCALATE]') }} }\n  ]\n}",
        "options": {}
      },
      "id": "line-push-admin",
      "name": "LINE Push (Admin escalate)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\": \"{{ $('Webhook').first().json.body.reply_token }}\",\n  \"messages\": [\n    { \"type\": \"text\", \"text\": {{ JSON.stringify($('Parse AI Output').first().json.ai.customer_reply) }} }\n  ]\n}",
        "options": {}
      },
      "id": "line-reply-escalate",
      "name": "LINE Reply (ESCALATE)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        840,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseCode": 200,
        "responseBody": "={ \"ok\": true }",
        "options": {}
      },
      "id": "respond-ok",
      "name": "Respond 200",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1100,
        0
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "IF: X-Internal-Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: X-Internal-Token": {
      "main": [
        [
          {
            "node": "Notion: Query EventLog (idempotency)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond 401",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Query EventLog (idempotency)": {
      "main": [
        [
          {
            "node": "IF: duplicate?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: duplicate?": {
      "main": [
        [
          {
            "node": "Respond 200 (deduped)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notion: Create EventLog page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Create EventLog page": {
      "main": [
        [
          {
            "node": "Notion: Query CustomerSession",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Query CustomerSession": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Parse AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Output": {
      "main": [
        [
          {
            "node": "Switch by action.type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch by action.type": {
      "main": [
        [
          {
            "node": "LINE Reply (ASK_MORE)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "LINE Reply (FAQ)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "LINE Reply (CHECK_AVAILABILITY)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notion: Create Booking",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "LINE Push (Admin escalate)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Create Booking": {
      "main": [
        [
          {
            "node": "LINE Reply (CREATE_BOOKING)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Push (Admin escalate)": {
      "main": [
        [
          {
            "node": "LINE Reply (ESCALATE)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Reply (ASK_MORE)": {
      "main": [
        [
          {
            "node": "Respond 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Reply (FAQ)": {
      "main": [
        [
          {
            "node": "Respond 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Reply (CHECK_AVAILABILITY)": {
      "main": [
        [
          {
            "node": "Respond 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Reply (CREATE_BOOKING)": {
      "main": [
        [
          {
            "node": "Respond 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Reply (ESCALATE)": {
      "main": [
        [
          {
            "node": "Respond 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "timezone": "Asia/Taipei"
  },
  "tags": []
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

A - LINE Incoming (Notion). Uses httpRequest, agent, lmChatOpenAi. Webhook trigger; 20 nodes.

Source: https://gist.github.com/wshe029/2f95dfc861cc6157e1a092b3c288d6cf — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

⏺ 🚀 How it works

Agent, Anthropic Chat, Output Parser Structured +6
AI & RAG

L&D_AgentsAI_ATIVO. Uses httpRequest, agent, googleCalendarTool, toolSerpApi. Webhook trigger; 93 nodes.

HTTP Request, Agent, Google Calendar Tool +9
AI & RAG

CLINICAINTEGRAL_secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 89 nodes.

Postgres, Mcp Client Tool, Google Drive Tool +14
AI & RAG

Remi 1.1. Uses lmChatOpenAi, memoryPostgresChat, openAi, postgres. Webhook trigger; 89 nodes.

OpenAI Chat, Memory Postgres Chat, OpenAI +7
AI & RAG

This n8n workflow orchestrates a powerful suite of AI Agents and automations to manage and optimize various aspects of an e-commerce operation, particularly for platforms like Shopify. It leverages La

Google Sheets, HTTP Request, Slack +10