8
n8n 中文网amn8n.com

AI驱动的食品订单处理系统,集成Facebook Messenger、Google表格和日历

高级

这是一个Lead Nurturing, AI Chatbot, Multimodal AI领域的自动化工作流,包含 26 个节点。主要使用 If, Code, Webhook, HttpRequest, GoogleSheets 等节点。 AI驱动的食品订单处理系统,集成Facebook Messenger、Google表格和日历

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "0d9842ac819c94ed608cf109ffea042fc9fa0d9e9bc828738c90c3953c1f318f"
  },
  "nodes": [
    {
      "id": "sticky_main_001",
      "name": "便签 - 主要描述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -300
      ],
      "parameters": {
        "color": 4,
        "width": 1000,
        "height": 900,
        "content": "## 📌 唐扬鸡块 - Messenger 订单自动化"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky_webhook_002",
      "name": "便签 - Webhook",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -100
      ],
      "parameters": {
        "color": 1,
        "width": 360,
        "height": 220,
        "content": "### Webhook 与验证"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky_ai_003",
      "name": "便签 - AI Agent",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        520
      ],
      "parameters": {
        "color": 1,
        "width": 340,
        "height": 220,
        "content": "### AI Agent 与记忆缓冲区"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky_parse_004",
      "name": "便签 - 解析",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1800,
        520
      ],
      "parameters": {
        "color": 1,
        "width": 380,
        "height": 200,
        "content": "### 订单解析与验证"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky_sheets_005",
      "name": "便签 - Google Sheets",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        260
      ],
      "parameters": {
        "color": 1,
        "width": 380,
        "height": 180,
        "content": "### Google Sheets 节点"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky_calendar_006",
      "name": "便签 - Google Calendar",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1960,
        180
      ],
      "parameters": {
        "color": 1,
        "width": 320,
        "height": 160,
        "content": "### Google Calendar"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky_message_007",
      "name": "便签 - 确认消息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2120,
        40
      ],
      "parameters": {
        "color": 1,
        "width": 360,
        "height": 170,
        "content": "### Messenger 确认"
      },
      "typeVersion": 1
    },
    {
      "id": "1b74aa53-b1aa-47ed-be39-49845e2aad96",
      "name": "AI Agent (订单助手)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        464
      ],
      "parameters": {
        "text": "={{ $json.body.entry[0].messaging[0].message.text }}",
        "options": {
          "systemMessage": "=### OPENING MESSAGE:\n👋 Hi po! Welcome to Karaage Pops – PureGold Carmona! 🍗\nThanks for messaging us! Here’s everything you need to know:\n\n📍 Location: https://maps.app.goo.gl/cpbXL1vHJqtdaGyP7 (PureGold Carmona)\n🕙 Operating Hours: Monday to Saturday, 10AM to 7PM\n🚚 Delivery: Saturday–Sunday only in Carmona (Min. 3 orders, ₱30 fee)\n\n🔥 Our Flavors – 9 Crispy Options!\nSMALL: PHP 69\nMEDIUM: PHP 99\nLARGE: PHP 129\n\nSalt & Pepper\nSpicy Buffalo 🌶️\nGarlic Parmesan ⭐\nYangnyeom (Korean-style)\nSweet & Spicy\nHoney Garlic 🍯\nSweet Teriyaki\nLemon Pepper\nCreamy Cheese 🧀\n\n🎉 Promo Alert! Large Karaage + Rice is now just ₱129 (from ₱139)! 💯\n----------------------------------------------------------------\n### Customer order - please fill out all required fields (send as a separate message):\n1. Full Name:\n2. Contact Number:\n3. Delivery Address:\n4. Time:\n5. Date:\n6. Order:\n----------------------------------------------------------------\n### UPSELL (Sent after order is received)\nWould you like to upsize or add any of the following?\n- Upgrade to Large Karaage + Rice – ₱129\n- Extra Rice – ₱15\n- Coke (can) – ₱25\n- Bottled Water – ₱15\n\nReply with \"Add: [item]\" or \"No, thank you!\""
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "a5ee9486-5c65-43d8-bc4a-209d4549451d",
      "name": "记忆缓冲区 (客户会话)",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "notes": "Order price list and product sizing stored for quick reference.",
      "position": [
        272,
        672
      ],
      "parameters": {
        "sessionKey": "={{ $json.body.entry[0].messaging[0].sender.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "ccf97b51-a7d1-43ab-8d58-4e5f74171d99",
      "name": "OpenRouter 模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        128,
        672
      ],
      "parameters": {
        "model": "deepseek/deepseek-chat:free",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "5476fda6-eb40-4047-b425-b61ffbdb1176",
      "name": "响应 200 OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        720,
        464
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "noData"
      },
      "typeVersion": 1.1
    },
    {
      "id": "61b85284-4114-4354-b94f-0a7221399b26",
      "name": "Webhook - FB Messenger",
      "type": "n8n-nodes-base.webhook",
      "position": [
        48,
        352
      ],
      "webhookId": "44b1ed59-bd9f-412f-aad1-11cea984b2de",
      "parameters": {
        "path": "fb-messenger-webhook",
        "options": {},
        "responseMode": "responseNode",
        "multipleMethods": true
      },
      "typeVersion": 2
    },
    {
      "id": "ef557297-ba25-4997-9fb9-26e3e89ea3e9",
      "name": "响应挑战",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        720,
        32
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $('Webhook - FB Messenger').item.json.query['hub.challenge'] }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5fdc09bb-5f86-4802-8df8-f028da9b7dac",
      "name": "验证 Webhook 订阅",
      "type": "n8n-nodes-base.if",
      "position": [
        432,
        128
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1c58f754-c63f-4744-98d9-0bebaef30c9b",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.query['hub.mode'] }}",
              "rightValue": "subscribe"
            },
            {
              "id": "12ba435c-90c1-450f-8801-0aaafbcf7808",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.query['hub.verify_token'] }}",
              "rightValue": "{{YOUR_FB_VERIFY_TOKEN}}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "send-text-http-001",
      "name": "发送消息到 FB (文本)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2000,
        96
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v13.0/{{FB_PAGE_ID}}/messages",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"recipient\": { \"id\": \"{{ $('Webhook - FB Messenger').item.json.body.entry[0].messaging[0].sender.id }}\" },\n  \"message\": { \"text\": {{JSON.stringify($('AI Agent (Order Assistant)').item.json.output)}} },\n  \"messaging_type\": \"RESPONSE\",\n  \"notification_type\": \"REGULAR\"\n}\n",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "{{FB_PAGE_ACCESS_TOKEN}}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "28330bd3-2fbc-4cc9-9373-305ddde8205e",
      "name": "便签 - 设置与描述 (原始)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 880,
        "height": 420,
        "content": "## 唐扬鸡块 - Messenger 订单自动化"
      },
      "typeVersion": 1
    },
    {
      "id": "cf4e10f5-941b-4673-bee5-a9ccc4fc309f",
      "name": "便签 - 使用说明 (原始)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        80
      ],
      "parameters": {
        "width": 1100,
        "height": 368,
        "content": "## 使用方法"
      },
      "typeVersion": 1
    },
    {
      "id": "e97638ca-146e-4470-b8ff-037db276ba07",
      "name": "响应 202 (错误回退)",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        720,
        224
      ],
      "parameters": {
        "options": {
          "responseCode": 202
        },
        "respondWith": "noData"
      },
      "typeVersion": 1.1
    },
    {
      "id": "send-image-http-001",
      "name": "发送消息到 FB (图片)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1280,
        368
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v13.0/{{FB_PAGE_ID}}/messages",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"recipient\": { \"id\": \"{{ $('Webhook - FB Messenger').item.json.body.entry[0].messaging[0].sender.id }}\" },\n  \"message\": { \"attachment\": { \"type\": \"image\", \"payload\": { \"url\": \"https://i.imgur.com/M4cryeH.jpg\", \"is_reusable\": true } } },\n  \"messaging_type\": \"RESPONSE\",\n  \"notification_type\": \"REGULAR\"\n}\n",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "{{FB_PAGE_ACCESS_TOKEN}}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "53ff0cdc-a4ad-4b08-a46f-11e99d6a2e93",
      "name": "检查菜单触发",
      "type": "n8n-nodes-base.if",
      "position": [
        976,
        464
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1f7edad-f67c-454f-a768-eae3a28f684b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "Here’s our FULL MENU OF FLAVORS and options for you to choose from"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c0ae83fc-68ec-4ef8-8200-2d0097c56a90",
      "name": "发送通用文本 (HTTP)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1312,
        560
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v13.0/{{FB_PAGE_ID}}/messages",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"recipient\": { \"id\": \"{{ $('Webhook - FB Messenger').item.json.body.entry[0].messaging[0].sender.id }}\" },\n  \"message\": { \"text\": {{JSON.stringify($('AI Agent (Order Assistant)').item.json.output)}} },\n  \"messaging_type\": \"RESPONSE\",\n  \"notification_type\": \"REGULAR\"\n}\n",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "{{FB_PAGE_ACCESS_TOKEN}}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "8e4ff0ef-c175-4af7-9dd2-17f34d4588d9",
      "name": "解析订单文本",
      "type": "n8n-nodes-base.code",
      "position": [
        2016,
        544
      ],
      "parameters": {
        "jsCode": "const text = $('Webhook - FB Messenger').first().json.body.entry[0].messaging[0].message.text;\nconst lines = text.split(/\\r?\\n/);\nconst result = {};\nlines.forEach(line => {\n  const [key, ...rest] = line.split(':');\n  if (key && rest.length) {\n    result[key.trim().replace(/^[^a-zA-Z0-9]+/g, '')] = rest.join(':').trim();\n  }\n});\nreturn [{ json: result }];\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "8599060b-82e6-423a-b840-4072f73f75c7",
      "name": "验证解析的订单",
      "type": "n8n-nodes-base.if",
      "position": [
        1712,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1f7edad-f67c-454f-a768-eae3a28f684b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Send Message to FB (Text)').item.json.output }}",
              "rightValue": "Full Name"
            },
            {
              "id": "f269fa0c-7291-454e-9738-e24979a82c8e",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Send Message to FB (Text)').item.json.output }}",
              "rightValue": "Date"
            },
            {
              "id": "818104ae-1325-4e6c-a109-378923f58104",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Send Message to FB (Text)').item.json.output }}",
              "rightValue": "Order"
            },
            {
              "id": "8b6790de-8552-4a1f-af86-324e72739c28",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Send Message to FB (Text)').item.json.output }}",
              "rightValue": "Delivery Address"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7319266e-8bb6-4ce4-9cbb-bb5983a3938a",
      "name": "响应原始项目 (调试)",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2032,
        784
      ],
      "parameters": {
        "options": {
          "responseCode": 100
        },
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.1
    },
    {
      "id": "20b91f65-03f6-4503-9126-64b7cb170c96",
      "name": "创建日历事件",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2000,
        336
      ],
      "parameters": {
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "{{YOUR_GOOGLE_CALENDAR_EMAIL}}",
          "cachedResultName": "{{YOUR_GOOGLE_CALENDAR_EMAIL}}"
        },
        "additionalFields": {
          "summary": "={{ $json.Order }} ORDERED BY {{ $json['Full Name'] }}"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "fe286031-e032-44ae-bc45-303dac0f8c56",
      "name": "追加或更新订单表",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1648,
        336
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json['Date'] }}",
            "Time": "={{ $json['Time'] }}",
            "Order": "={{ $json['Order'] }}",
            "Full Name": "={{ $json['Full Name'] }}",
            "Contact Number": "={{ $json['Contact Number'] }}",
            "Delivery Address": "={{ $json['Delivery Address'] }}"
          },
          "schema": [
            {
              "id": "Full Name",
              "type": "string",
              "displayName": "Full Name"
            },
            {
              "id": "Contact Number",
              "type": "string",
              "displayName": "Contact Number"
            },
            {
              "id": "Delivery Address",
              "type": "string",
              "displayName": "Delivery Address"
            },
            {
              "id": "Time",
              "type": "string",
              "displayName": "Time"
            },
            {
              "id": "Date",
              "type": "string",
              "displayName": "Date"
            },
            {
              "id": "Order",
              "type": "string",
              "displayName": "Order"
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Full Name"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "{{YOUR_SHEET_GID_OR_NAME}}",
          "cachedResultName": "{{YOUR_SHEET_GID_OR_NAME}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "{{YOUR_GOOGLE_SHEET_ID}}",
          "cachedResultName": "{{YOUR_GOOGLE_SHEET_NAME}}"
        }
      },
      "typeVersion": 4.6
    }
  ],
  "pinData": {},
  "connections": {
    "OpenRouter Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent (Order Assistant)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse Order Text": {
      "main": [
        [
          {
            "node": "Append or Update Orders Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Parsed Order": {
      "main": [
        [
          {
            "node": "Parse Order Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Raw Items (Debug)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Menu Trigger": {
      "main": [
        [
          {
            "node": "Send Message to FB (Image)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Generic Text (HTTP)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - FB Messenger": {
      "main": [
        [
          {
            "node": "Validate Webhook Subscription",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent (Order Assistant)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Generic Text (HTTP)": {
      "main": [
        [
          {
            "node": "Validate Parsed Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Message to FB (Text)": {
      "main": [
        [
          {
            "node": "Check for Menu Trigger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent (Order Assistant)": {
      "main": [
        [
          {
            "node": "Respond 200 OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or Update Orders Sheet": {
      "main": [
        [
          {
            "node": "Create Calendar Event",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Message to FB (Text)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Webhook Subscription": {
      "main": [
        [
          {
            "node": "Respond Challenge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond 202 (Error fallback)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Memory Buffer (Customer Session)": {
      "ai_memory": [
        [
          {
            "node": "AI Agent (Order Assistant)",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客户培育, AI 聊天机器人, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量26
分类3
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
外部链接
在 n8n.io 查看

分享此工作流