n8n AI 客服助手:WhatsApp 实时问答 + 网站自动爬取
输入:WhatsApp 用户消息 → 处理:AI Agent 实时爬取网站内容并生成回答 → 输出:WhatsApp 回复(支持 24h 窗口模板消息)
- 给谁
- 需要为网站部署 WhatsApp AI 客服的中小企业、开发者或代理商
- 你会得到
- 用户通过 WhatsApp 提问后,AI 实时爬取指定网站内容作答,支持多轮对话记忆;超时自动发送预批准模板消息重新开启对话
硬约束
前置条件:n8n 实例;OpenAI API key;Meta WhatsApp Cloud API 号码 + 永久令牌;Supabase/Postgres 数据库;lemolex 会员 auth-token($29/月)。总耗时约 15 分钟。
他们做了什么
作者 lemolex 在 n8n 平台发布了一个模板工作流,展示如何通过 WhatsApp 触发 AI 客服:AI Agent 使用 gpt-4o-mini 模型,配备 list_links 和 get_page 两个 HTTP 工具实时爬取用户指定的网站内容,结合 Postgres 数据库存储对话记忆,在 Meta WhatsApp 24 小时服务窗口内自由回复用户,超时后自动发送预批准的模板消息重新开启对话。cleanAnswer 节点用 JavaScript 清理 AI 输出中的 Markdown 格式以适配 WhatsApp 纯文本。
效果如何
模板描述声称整个设置可在约 15 分钟内完成,可替代每月 $300–$500 的第三方 AI 客服 SaaS 工具,或作为白标服务转售给客户(author_report)。
值得知道
核心爬取工具(list_links、get_page)的端点托管于 lemolex.app.n8n.cloud,需要付费会员($29/月)获取 auth-token 才能调用;若工具返回 404,AI 会回复 "Non-subscribed user"。如果不需要 24 小时窗口检查,可删除 "24-hour window check"、"If" 和 "Send Pre-approved Template Message to Reopen the Conversation" 三个节点,直接将 AI Agent 连接到 cleanAnswer 节点(来源不推荐)。WhatsApp 模板消息需在 Meta 后台预先审批。本站未实际运行此工作流。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- OpenAI Chat Model 节点:绑定OpenAI API 凭证。
- WhatsApp Trigger 节点:绑定whatsAppTriggerApi 凭证。
- Send Pre-approved Template Message to Reopen the Conversation 节点:绑定whatsAppApi 凭证。
- Send AI Agent's Answer 节点:绑定whatsAppApi 凭证。
- Postgres Users Memory 节点:绑定Postgres 凭证。
需要替换的配置
- 源模板来自 n8n 公开库 #3859(约 12 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-25
步骤
导入模板
在 n8n 中打开模板页面 https://n8n.io/workflows/3859/,点击「Use workflow」导入。导入后应看到包含 AI Agent、list_links、get_page、WhatsApp Trigger、Postgres Users Memory 等节点的工作流。
配置爬取工具参数
打开 list_links 和 get_page 两个 HTTP Request 工具节点,在 Body Parameters 中填入:Name=auth-token,Value=你的会员密钥(从 lemolex.gumroad.com 获取);Name=url,Value=你的网站根域名(如 https://www.example.com)。两个节点的 auth-token 和 url 需分别配置。
运行提示词 · 来源原文。list_links 工具节点的 Tool Description 字段
Returns up to 100 unique, fully-qualified INTERNAL links for a given page. Input (JSON body the model must supply) { "url": "<absolute https://…>" } Behaviour • Crawls only the domain of the input URL. • Converts relative <a href> values to absolute URLs. • Drops empty roots ("/"), mailto:, tel:, javascript:, and off-site links. • De-duplicates the list. • Responds with a JSON object: { "urls": [ "<link-1>", "<link-2>", … ] } Use this tool when you need a navigation map of the current page. Pass one of the returned URLs back into other tools (e.g. get_text) to read its content.运行提示词 · 来源原文。get_page 工具节点的 Tool Description 字段
Fetches the fully-rendered **plain text** of a single web. • Input : { "url": "<absolute https://…>" } • Auth : token is sent as HTTP basic-auth. • Query : url=<encoded url> • Output : { "text": "<visible text of the body>", "url": "<same url>" } • The "text" field already has **all HTML tags removed** . • Use this tool whenever you need the actual words that appear on the page—product details, prices, stock lines, shipping terms, payment options, company policies, etc. • Do **not** call it on off-site links or mailto:/tel:/javascript: pseudo-links.修改 AI Agent 系统提示词
打开 AI Agent 节点,在 System Message 中将 [Company Name] 替换为你的公司名,将 https://www.your-company-url.com 替换为你的网站根域名。检查全文确保两处均已替换。此提示词控制 AI 的搜索策略、回答格式和 404 处理。
运行提示词 · 来源原文。AI Agent 节点的 System Message 字段(需替换 [Company Name] 和 URL 变量)
=You are [Company Name]’s real-time website assistant for https://www.your-company-url.com. AVAILABLE TOOLS • list_links(url) → { urls:[ … ] } — returns up to 100 internal links from that page • get_page(url) → { text:"…" } — returns the visible, tag-free text of the page (JavaScript rendered if needed) SEARCH STRATEGY 1. Start with list_links on the root page. 2. Pick ≤ 5 links whose URL or anchor text best match the user’s question (producto, pago, envío, servicio, política, etc.). 3. For each chosen link call get_page once. 4. Read the returned text and look for the answer. 5. If the answer is still unknown, you may repeat steps 1-4 one level deeper. 6. Stop after two list_links rounds **or** eight get_page calls (whichever comes first). ANSWER RULES • Reply in clear and friendly toon **as part of [Company Name]** (use “we”, “our”). • Keep answers concise but complete. • **No Markdown ni símbolos de formato. Nunca uses \*, **, \_, \~, ni [texto](url).** Write urls like: Descriptive Text ␣URL Ej.: Combos https://… • Quote the exact wording for facts such as stock status, prices, envíos, métodos de pago, garantías o políticas. • If the information is not on the site, reply exactly: “I can't find that information on our site right now. Do you want me to put you through to a human agent?” • Stay on-domain; ignore mailto:, tel:, javascript:, or off-site links. • Finally, if any of the tools returns a status code 404, then reply: "Non-subscribed user."连接凭证
依次配置以下凭证:OpenAI Chat Model 节点 → OpenAI API key;Postgres Users Memory 节点 → Supabase/Postgres 连接信息;WhatsApp Trigger、Send Pre-approved Template Message、Send AI Agent's Answer 三个节点 → Meta WhatsApp Cloud API 凭证。在 Send Pre-approved Template Message 节点中选择预批准的模板消息。
配置 Meta Webhook
在 Meta 开发者后台的 WhatsApp 产品设置中,将 Webhook URL 指向 n8n 中 WhatsApp Trigger 节点显示的 Webhook URL(格式通常为 https://your-n8n-instance/webhook/...)。验证并订阅 messages 事件。
测试运行
在 n8n 中点击「Execute Trigger」,然后从已绑定的 WhatsApp 号码发送「Hi」。观察 AI Agent 是否爬取网站并返回答案。若 24 小时内无互动,下次用户消息会触发预批准模板消息重新开启对话。
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限
这一段是提示词,页面不会在这里插入广告。
你正在搭建一个基于 n8n 的 WhatsApp AI 客服工作流。请确认你已准备好:n8n 实例、OpenAI API key、Meta WhatsApp Cloud API 凭证、Supabase/Postgres 数据库,以及 lemolex 会员 auth-token。先检查 list_links 和 get_page 两个工具节点的 URL 和 auth-token 是否已填入,再修改 AI Agent 的 System Message 中的公司名和域名,最后连接所有凭证并配置 Meta Webhook。
此提示词用于搭建前的准备检查,不是节点运行指令。实际节点提示词见各步骤 prompts。
来源
Ai customer support assistant · WhatsApp ready · works for any business · lemolex · n8n.io · 2025-05-04
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。