8
n8n 中文网amn8n.com

酒店前台 WhatsApp 接待系统

高级

这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 18 个节点。主要使用 Code, Redis, WhatsApp, MySqlTool, Agent 等节点。 集成 WhatsApp、Gemini 模型切换、Redis 和 Google Sheets 的酒店前台系统

前置要求
  • Redis 服务器连接信息
  • MySQL 数据库连接信息
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "07df66e33836083697e8bd7e53a57a2a1f404ad7aabcc82daa752a2b5a254167"
  },
  "nodes": [
    {
      "id": "2ccdee26-1db9-4717-b1ad-79651d7d65dc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -96
      ],
      "parameters": {
        "color": 4,
        "width": 336,
        "height": 224,
        "content": "💬 工作流概览"
      },
      "typeVersion": 1
    },
    {
      "id": "750f8f4d-35dd-4a82-90fd-0ef01a89888b",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1456,
        -16
      ],
      "parameters": {
        "text": "={{ $('WhatsApp Trigger').item.json.messages[0].text.body }}",
        "options": {
          "systemMessage": "You are a helpful AI assistant tasked with answering questions about hotel bookings.\nYou have access to a MySQL database with tables like 'bookings', 'guests', 'rooms', etc.\n\nIMPORTANT SECURITY RULE: YOU ARE STRICTLY FORBIDDEN FROM PERFORMING ANY DATABASE WRITE OPERATIONS (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, etc.).\nYou must ONLY generate valid SQL SELECT statements.\n\nWhen a user asks a question, translate it into an appropriate SQL SELECT query."
        },
        "promptType": "define"
      },
      "retryOnFail": false,
      "typeVersion": 2
    },
    {
      "id": "1a267886-51fa-4500-ab95-6200cc512a1a",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1600,
        192
      ],
      "parameters": {
        "sessionKey": "={{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "75cab8e8-7d1d-4730-a4b4-f9ba7f4f651e",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1280,
        384
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "2CxiwuZKBBT7X4pw",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c3229f34-a2d5-4472-b54d-9c960a3baa0f",
      "name": "定价",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1728,
        192
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13yvxKTOWC4lgMLPWtVW_RELRZWdZHwUon_xOk4rF1X0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "13yvxKTOWC4lgMLPWtVW_RELRZWdZHwUon_xOk4rF1X0"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "CDun7Si7Sf8O9FcN",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "0ab80c8e-e0ae-48d3-ace7-7afa25cdadc1",
      "name": "Google Gemini 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1456,
        384
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "Vhf40F3r42Vi7ZiS",
          "name": "akzzyforza Gemini"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1f14faf9-f819-4a3d-9ca5-8dd35d814e95",
      "name": "WhatsApp 触发器",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        80,
        -16
      ],
      "webhookId": "dbb71091-820e-4c6f-b925-f1632b03d751",
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "id": "c3SMCxa8j0SOP79z",
          "name": "WhatsApp OAuth account Magic"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "78022ecc-79b5-4f44-a209-155dd7c9e967",
      "name": "模型决策器",
      "type": "n8n-nodes-base.code",
      "position": [
        752,
        -16
      ],
      "parameters": {
        "jsCode": "let data;\ntry {\n  data = $json.value ? JSON.parse($json.value) : null;\n} catch (e) {\n  data = null;\n}\n\nlet modelIndex;\nlet shouldSet = false;\n\nif (data && typeof data.modelIndex === 'number') {\n  // Alternate: flip the previous modelIndex\n  modelIndex = data.modelIndex === 0 ? 1 : 0;\n  shouldSet = true; // store the new one\n} else {\n  // If no data, default to model 0 and store it\n  modelIndex = 0;\n  shouldSet = true;\n}\n\nreturn [\n  {\n    json: {\n      modelIndex,\n      shouldSet\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "707df459-df55-4686-b64e-3d99c1380e03",
      "name": "发送消息",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2016,
        -16
      ],
      "webhookId": "df4ef464-f28e-441d-a9da-cfcd5f64c9c2",
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "723548604171403",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.messages[0].from }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "9Il95VjdrW30AtrZ",
          "name": "WhatsApp account Magic valley"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8a9c3637-4e4d-4445-9c3b-c584e24dbdb5",
      "name": "在 MySQL 中执行 SQL 查询",
      "type": "n8n-nodes-base.mySqlTool",
      "position": [
        1856,
        192
      ],
      "parameters": {
        "query": "{{ $('AI Agent').item.json.query }}",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "mySql": {
          "id": "3bfA94Mi8Qx2AnYZ",
          "name": "MySQL account"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "e1b30ed3-0ad7-417f-95de-752ab618c89a",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -256
      ],
      "parameters": {
        "color": 5,
        "width": 544,
        "height": 176,
        "content": "⚙️ 模型切换系统"
      },
      "typeVersion": 1
    },
    {
      "id": "13bbf86c-a3cb-4fec-b66f-9f8cd912f494",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        -272
      ],
      "parameters": {
        "color": 6,
        "width": 448,
        "height": 208,
        "content": "🧠 智能酒店助手"
      },
      "typeVersion": 1
    },
    {
      "id": "448b3618-9ccd-45d1-b905-bedf5540d877",
      "name": "检查消息",
      "type": "n8n-nodes-base.code",
      "position": [
        304,
        -16
      ],
      "parameters": {
        "jsCode": "const msg = $json.messages?.[0]?.text;\n\nif (!msg) {\n  // Exit early if no text message\n  return [];\n}\n\nreturn items;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f13bf318-7585-4787-a7ca-c083617a9e8f",
      "name": "存储用户号码",
      "type": "n8n-nodes-base.redis",
      "position": [
        976,
        -16
      ],
      "parameters": {
        "key": "=llm-user:{{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}",
        "ttl": 3600,
        "value": "={{ JSON.stringify({ modelIndex: $json.modelIndex }) }}",
        "expire": true,
        "operation": "set"
      },
      "credentials": {
        "redis": {
          "id": "7OPmbqMTy2N5aprY",
          "name": "Redis account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ca6ba30a-da25-42e2-b9c0-f30b0438ab8e",
      "name": "检查用户号码",
      "type": "n8n-nodes-base.redis",
      "position": [
        528,
        -16
      ],
      "parameters": {
        "key": "=llm-user:{{ $json.contacts[0].wa_id }}",
        "options": {},
        "operation": "get"
      },
      "credentials": {
        "redis": {
          "id": "7OPmbqMTy2N5aprY",
          "name": "Redis account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "eeeac186-0627-45f9-a122-c5b0ac50a537",
      "name": "选择模型",
      "type": "@n8n/n8n-nodes-langchain.modelSelector",
      "position": [
        1328,
        192
      ],
      "parameters": {
        "rules": {
          "rule": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "61173b3f-c09e-4efb-aae0-5af12aed3b1e",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.modelIndex}}",
                    "rightValue": 0
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6fd19391-2c15-42a6-82db-152976b1d6d3",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.modelIndex}}",
                    "rightValue": 1
                  }
                ]
              },
              "modelIndex": 2
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a317cb5a-56a2-41e7-8ab8-3a0758c09c11",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        160
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 192,
        "content": "Redis 获取节点"
      },
      "typeVersion": 1
    },
    {
      "id": "86bfc5ea-e65c-4a6c-bd53-1ef3d473b97f",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        160
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 192,
        "content": "Redis 设置节点"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Pricing": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Choose Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check Message": {
      "main": [
        [
          {
            "node": "Check User Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model Decider": {
      "main": [
        [
          {
            "node": "Store User Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Check Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check User Number": {
      "main": [
        [
          {
            "node": "Model Decider",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store User Number": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Choose Model",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Choose Model",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Execute a SQL query in MySQL": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客服机器人, AI 聊天机器人

需要付费吗?

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

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

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

作者
Akshay

Akshay

@akshay6

Automation Engineer

外部链接
在 n8n.io 查看

分享此工作流