r/n8n WhatsApp 自动化线程暴露了生产差距:大多数机器人都是基于模板的,并且会打破脚本外的问题。通过 Scavio 添加实时 Web 上下文可以修复此问题。这会遍历 n8n 堆栈。
前置条件
- n8n 云或自托管
- WhatsApp Business API 帐户(元验证)
- Scavio API 密钥
- LLM API 密钥 (Claude/OpenAI)
操作指南
步骤 1: 将 WhatsApp Business Webhook 连接到 n8n
n8n 有一个原生 WhatsApp 触发器节点。
Text
// n8n UI: Add Trigger > WhatsApp Business Cloud > 'On message received'步骤 2: 检测意图:脚本化与自由形式
根据消息内容切换节点。
Text
// Switch node:
// Route 1: message matches /pricing|hours|address/ -> static FAQ response
// Route 2: anything else -> LLM-grounded answer path步骤 3: 对于自由形式:通过 Scavio 搜索实时上下文
HTTP 请求节点,Scadio /api/v1/search。
JSON
// HTTP node: POST https://api.scavio.dev/api/v1/search
// Headers: x-api-key: <key>
// Body: { "query": "{{$json.messages[0].text.body}} site:yourcompany.com" }步骤 4: LLM 节点:将答案纳入 Scavio 结果中
将最佳结果传递到 LLM 提示符中。
Text
// LLM node prompt:
// Answer the user's question using ONLY these sources from our website:
// {{$json.organic_results.slice(0,3).map(r => `- ${r.title}: ${r.snippet} (${r.link})`).join('\n')}}
// Question: {{$node['WhatsApp Trigger'].json.messages[0].text.body}}步骤 5: 将 LLM 答案发送回 WhatsApp
具有 LLM 输出的 WhatsApp Send 节点。
Text
// WhatsApp Send node:
// To: {{$node['WhatsApp Trigger'].json.contacts[0].wa_id}}
// Body: {{$json.choices[0].message.content}}Python 示例
Python
# n8n is the deliverable. Per-conversation cost: 2 Scavio calls + 1 LLM call + WA conversation fee = ~$0.03-0.15.JavaScript 示例
JavaScript
// n8n nodes are JS-flavored expressions; full TS not needed.预期输出
JSON
Production WhatsApp bot that answers free-form user questions from your live website content, sourced and grounded. Setup time: ~3 hours including Meta Business Account verification (1-3 day external lag).