Tutorial

How to Build a Production WhatsApp Bot with n8n + Scavio

An r/n8n thread (23 upvotes) surfaced the live-context gap. Step-by-step n8n + WhatsApp Business API + Scavio for grounded bot answers.

An r/n8n WhatsApp automation thread surfaced the production gap: most bots are template-based and break on out-of-script questions. Adding live web context via Scavio fixes it. This walks the n8n stack.

Prerequisites

  • n8n cloud or self-host
  • WhatsApp Business API account (Meta-verified)
  • Scavio API key
  • An LLM API key (Claude/OpenAI)

Walkthrough

Step 1: Wire WhatsApp Business webhook into n8n

n8n has a native WhatsApp Trigger node.

Text
// n8n UI: Add Trigger > WhatsApp Business Cloud > 'On message received'

Step 2: Detect intent: scripted vs free-form

Switch node based on message content.

Text
// Switch node:
// Route 1: message matches /pricing|hours|address/ -> static FAQ response
// Route 2: anything else -> LLM-grounded answer path

Step 3: For free-form: search live context via Scavio

HTTP Request node, Scavio /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" }

Step 4: LLM node: ground the answer in Scavio results

Pass top results into the LLM prompt.

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}}

Step 5: Send LLM answer back to WhatsApp

WhatsApp Send node with the LLM output.

Text
// WhatsApp Send node:
// To: {{$node['WhatsApp Trigger'].json.contacts[0].wa_id}}
// Body: {{$json.choices[0].message.content}}

Python Example

Python
# n8n is the deliverable. Per-conversation cost: 2 Scavio calls + 1 LLM call + WA conversation fee = ~$0.03-0.15.

JavaScript Example

JavaScript
// n8n nodes are JS-flavored expressions; full TS not needed.

Expected Output

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).

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

n8n cloud or self-host. WhatsApp Business API account (Meta-verified). Scavio API key. An LLM API key (Claude/OpenAI). A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

An r/n8n thread (23 upvotes) surfaced the live-context gap. Step-by-step n8n + WhatsApp Business API + Scavio for grounded bot answers.