How to build a WhatsApp chatbot with n8n
An n8n WhatsApp chatbot is an automated messaging agent built by connecting n8n — an open-source workflow automation platform with 400+ integrations — to Meta’s WhatsApp Business Cloud API. When a message arrives, WhatsApp delivers it to a webhook, n8n processes the logic (routing, AI responses, database lookups), and the reply is pushed back to the user, all without a third-party chatbot SaaS in the middle. Learning how to build a WhatsApp chatbot with n8n gives you complete control over your messaging workflows and reduces vendor lock-in.
n8n acts as the orchestration layer between WhatsApp and your business systems — your CRM, an OpenAI model, a vector store, or a custom ERP. Unlike closed chatbot builders that lock your logic behind a monthly subscription, n8n runs as a visual workflow you fully own and can self-host, which is why practitioners on r/n8n have published guides building functional bots in under 15 minutes (Reddit, March 2025). For the canonical low-code reference, n8n maintains its own step-by-step guide with a free template (blog.n8n.io).
This guide reflects topical expertise in n8n WhatsApp automation and the WhatsApp Business API. It is grounded in official n8n documentation and community resources rather than first-party claims; figures are attributed to their sources where cited. Last updated June 2026.
How the webhook-driven message flow works
WhatsApp Business Cloud API delivers every inbound message to a registered webhook URL. n8n’s WhatsApp Trigger node captures that payload, then the workflow executes in sequence:
- Webhook receives the incoming message (text, voice, or menu selection)
- n8n parses the sender ID, message body, and metadata
- Logic runs — AI agent, RAG lookup against a product catalog, or a deterministic decision tree
- Response node sends the reply back through the WhatsApp Cloud API
Returning workflow results to WhatsApp is the fundamental loop every n8n bot depends on, as documented in n8n’s own community resources (Reddit, January 2025). The official n8n template library even ships a Sales Agent bot backed by a product-catalog vector store (n8n workflow 2465), which you can import directly into your instance and adapt.
A typical first build: the option-menu bot
Before adding AI, practitioners generally find it useful to ship a deterministic option-menu bot first — the same pattern a medical practice described in the n8n community for appointment scheduling, where a patient messages the clinic and receives a numbered list of options like “schedule an appointment” or “check hours” (community.n8n.io, Dec 2025). A typical implementation looks like this:
- The WhatsApp Trigger node fires on any inbound message.
- A Switch node inspects
messages[0].text.bodyand matches “1”, “2”, or “3”. - Each branch returns a fixed reply via the WhatsApp Business Cloud API node — for example, branch “1” returns available appointment slots from a calendar lookup.
- An unmatched message returns the menu again.
This stage requires no LLM, no token spend, and no risk of a fabricated answer — which is why it is the recommended starting point before layering on the AI capabilities described later. n8n’s exportable JSON means you can save this workflow, version it in Git, and re-import it on any instance, so a working menu bot is a reproducible artifact rather than a one-off configuration.
Why self-hosted n8n compares well against SaaS chatbot builders
Self-hosted n8n avoids the per-message and per-seat pricing that can inflate hosted chatbot platforms. A self-hosted n8n instance typically runs on a $5–$20/month VPS regardless of message volume, while hosted builders often charge per conversation. The trade-off is real and worth stating plainly: you take on the operational responsibility of running, patching, and monitoring the server yourself, whereas a SaaS builder handles uptime and updates for you. For teams without any infrastructure experience, that operational burden can outweigh the cost savings.
| Factor | Self-hosted n8n | SaaS chatbot builder |
|---|---|---|
| Pricing model | Flat VPS cost | Per-message / per-seat |
| Data ownership | On your server | Vendor-hosted |
| Workflow logic | Fully exportable (JSON) | Locked in platform |
| GDPR control | Direct | Depends on vendor |
| Operational effort | You manage uptime/patching | Vendor manages |
Data control matters most for SMEs handling customer conversations under GDPR. Self-hosting keeps every message on infrastructure you govern — no third party reading or training on your customer data. If you lack in-house operations capacity, n8n’s own managed Cloud plan is a reasonable middle ground that still avoids per-task billing.
What do you need before building a WhatsApp chatbot with n8n?
Building a WhatsApp chatbot with n8n requires four core assets:
- A Meta Business account with WhatsApp Cloud API access
- A self-hosted n8n instance (a recent stable release is recommended)
- A verified dedicated phone number not tied to a personal WhatsApp account
- At least one approved message template for proactive notifications
Meta provides a free tier of service conversations per month, which keeps the entry cost low for most SMEs; check the current free-tier figure in Meta’s official pricing documentation, as these allowances are revised periodically.
Meta Business account and WhatsApp Cloud API access
A Meta Business account and WhatsApp Cloud API access form the official, free-to-host gateway between n8n and WhatsApp. Unlike the legacy On-Premises API, the Cloud API is hosted by Meta at no per-seat charge, which avoids the BSP markups that some resellers add. Register through the Meta for Developers portal, create a Business App, and add the WhatsApp product to generate your access token and Phone Number ID. The n8n setup guide walks through this Meta-side configuration in detail (blog.n8n.io).
Self-hosted n8n instance
A self-hosted n8n instance is the standard choice for production chatbots that handle customer data. Deploy via Docker on a low-cost VPS (Hetzner, DigitalOcean) or AWS EC2 — a small two-core instance comfortably handles thousands of messages daily. Self-hosting avoids the per-execution pricing that increases costs at scale on per-task platforms. A single Docker Compose stack can spin up n8n with persistent Postgres storage in a few minutes; n8n’s official installation docs cover the recommended environment variables and reverse-proxy setup.
Verified phone number and message templates
WhatsApp requires a dedicated phone number that is not registered to a personal WhatsApp account. Display-name verification through Meta Business Manager typically clears within a few business days. Message templates — pre-approved formats for any message sent outside the 24-hour customer service window — must pass Meta review before use; approval times vary, and utility and authentication templates generally clear faster than marketing templates. Always confirm current review timing in Meta’s official template documentation rather than relying on community estimates.
Prerequisites checklist
- Meta Business Manager account — verified business entity
- WhatsApp Cloud API access — App ID, Phone Number ID, permanent access token
- Self-hosted n8n — Docker or AWS EC2 with a public HTTPS endpoint for webhooks
- Dedicated phone number — not tied to any existing WhatsApp account
- SSL certificate — required for the n8n webhook URL (Let’s Encrypt via Caddy or Traefik)
- At least one approved message template — for proactive notifications
- An LLM API key — OpenAI, Anthropic, or a self-hosted model for response generation (optional for a menu-only bot)
Configure a public webhook URL before touching any workflow logic — Meta validates the endpoint with a challenge token during setup, and a missing HTTPS certificate is one of the most common failure points in first-time deployments.
How do you build the WhatsApp chatbot step by step?
Building an n8n WhatsApp chatbot follows four core stages: capturing the incoming message via webhook, routing it by intent, storing conversation context, and generating a guarded AI response. A working prototype is generally achievable in a few hours for a developer already familiar with n8n; community guides on r/n8n demonstrate simpler no-code menu bots assembled in under 15 minutes (Reddit, March 2025). The exact time depends heavily on how much AI logic, memory, and error handling you add.
Step 1: Configure the webhook and verify the token
- Create a Webhook node in n8n set to HTTP method GET (for verification) and POST (for messages). Copy the production URL into your Meta WhatsApp Business app under the Webhooks configuration.
- Verify the token by adding an IF node that checks
hub.verify_tokenagainst your stored value and returnshub.challenge. Meta rejects any webhook that fails this handshake quickly, so respond promptly. - Parse the incoming payload using a Set or Function node to extract
messages[0].text.body, the sender’swa_id, and the message timestamp. WhatsApp nests these fields several levels deep underentry[0].changes[0].value.
A common gotcha: Meta sends the GET verification request only once, at the moment you save the webhook in the Meta dashboard. If your n8n workflow is not active and listening at that instant, the handshake fails silently and you see no inbound messages. Activate the workflow first, then save the webhook on the Meta side.
Step 2: Add conditional routing and intent detection
Conditional routing decides what happens next based on the parsed message. Use a Switch node to branch on keywords (“pricing,” “support,” “hours”) for deterministic paths, then fall back to an AI intent classifier only when no keyword matches. Keyword-first routing handles a large share of inbound messages without an LLM call, which reduces token costs and latency. The exact share depends on your customer base, so log unmatched messages to measure your real hit rate rather than assuming a fixed percentage.
Step 3: Implement session memory with a database node
Session memory keeps the conversation coherent across multiple messages. Connect a Postgres or Redis node keyed on the sender’s wa_id to read the last N messages before generating a reply, then write the new exchange back after responding.
- Postgres — durable, queryable, ideal for audit trails and analytics.
- Redis — sub-millisecond reads, ideal for high-volume bots with TTL-based session expiry.
A practical tip: cap the history you re-inject into the prompt (for example, the last 6–10 turns). Unbounded context inflates token costs and can degrade response quality once the window fills with stale conversation.
Step 4: Connect an AI model with deterministic guardrails
AI guardrails reduce the chance the model invents facts or goes off-script. Pass a strict system prompt that defines scope, set a low temperature (commonly 0.1–0.3) to reduce randomness, and inject only retrieved knowledge-base context rather than letting the model freelance. Wrap the output in a validation node that rejects responses missing required fields or containing forbidden phrases. Constrained prompting plus low temperature generally produces fewer fabricated answers than a default high-temperature configuration — an important distinction between a chatbot you can trust with customers and one that becomes a liability. The n8n RAG template (workflow 2465) demonstrates the retrieval-augmented pattern using a product-catalog vector store, which is the recommended approach for grounding answers in your own data.
How do you add human handoff and avoid AI hallucinations?
Human handoff routes uncertain or high-stakes conversations to a live agent, while hallucination guardrails stop your chatbot from inventing answers. Both rely on confidence thresholds, escalation triggers, and complete logging — the difference between a deterministic assistant and a probabilistic liability that might quote a fake price to a real customer.
Chatbots deployed without handoff logic tend to produce a meaningful rate of confidently wrong responses on edge-case queries; adding the three controls below substantially reduces that rate in practice. Treat any specific reduction figure as something you must measure against your own logs, not a guarantee.
Setting escalation triggers to live agents
Escalation triggers are conditions that hand a conversation to a human the moment the bot exceeds its competence. In n8n, build these as an IF node that branches before any LLM response reaches the customer.
- Keyword triggers: Words like “refund,” “complaint,” “legal,” or “speak to a human” route instantly to your support queue via a Slack or WhatsApp notification.
- Sentiment triggers: Detect frustration (repeated questions, negative sentiment) and escalate before the customer churns.
- Transaction triggers: Any request touching payments, account changes, or contracts goes to a verified agent — never an AI.
Using confidence thresholds and fallback responses
Confidence thresholds ask the LLM to score its own certainty and refuse to answer when that score drops below a set value. Configure your model to return a structured JSON output containing both an answer and a confidence field between 0 and 1. Note that self-reported confidence is an imperfect signal — models can be confidently wrong — so pair it with retrieval grounding and keyword escalation rather than relying on it alone.
- Set a threshold — a value around 0.75 is a common starting point for customer-facing bots.
- Below threshold, suppress the generated answer entirely.
- Return a fixed fallback: “Let me connect you with a specialist who can confirm that.”
- Trigger the handoff node and log the unanswered query for review.
Fallback responses are safer than hallucinated answers. A bot that admits it doesn’t know preserves trust; a bot that fabricates a delivery date erodes it.
Logging for transparency and audit
Logging captures every message, confidence score, escalation, and model decision into a database your team can audit. Pipe each n8n run into Postgres, Google Sheets, or Supabase with timestamps, user IDs, the raw LLM output, and the final delivered response.
Audit logs serve three purposes: they support compliance for regulated industries, they surface recurring low-confidence queries that signal knowledge-base gaps, and they let you measure exactly when human oversight intervened. For GDPR, remember that storing WhatsApp message content makes you a data controller — apply retention limits, a lawful basis for processing, and a deletion path for data-subject requests. Transparency is not optional: a chatbot you can’t audit is a chatbot you can’t fully trust.
How much does an n8n WhatsApp chatbot cost vs Zapier?
A self-hosted n8n WhatsApp chatbot costs roughly $5–$20/month in server fees plus WhatsApp conversation charges, while the same workflow on Zapier typically runs higher once you exceed free task limits because of per-task pricing. For an SME handling several thousand conversations monthly, n8n’s flat model can produce meaningful annual savings — but the size of those savings depends on your volume, plan tier, and how much engineering time you spend self-hosting. The figures below are illustrative ranges based on published list pricing, not guaranteed outcomes; confirm current rates on each vendor’s pricing page.
n8n vs Zapier vs SaaS chatbot platforms
| Factor | n8n (self-hosted) | Zapier | SaaS chatbot platform |
|---|---|---|---|
| Base cost | ~$5–$20/mo (VPS) | Tiered subscription | Tiered subscription |
| Pricing model | Flat (unlimited executions) | Per-task | Per-contact / per-seat |
| Workflow complexity | Unlimited nodes & branching | Limited multi-step logic | Templated, lower flexibility |
| Data ownership | Full (on your server) | Vendor-hosted | Vendor-locked |
| Custom AI / RAG | Native (any LLM) | Restricted | Vendor’s model only |
| Operational effort | Self-managed | Fully managed | Fully managed |
WhatsApp conversation-based pricing breakdown
The WhatsApp Business Platform charges per 24-hour conversation window rather than per message. Meta uses category-based pricing where utility and service conversations are priced differently from marketing ones, and a monthly free tier of service conversations applies. Rates vary significantly by country. Because Meta revises these categories and rates periodically, always check Meta’s official conversation-based pricing documentation for the current figures before forecasting costs. Critically, these WhatsApp fees apply identically whether you run n8n or Zapier — the orchestration layer is where costs diverge.
Annual savings projection for SMEs
The savings from choosing self-hosted n8n over a per-task platform grow with volume, because n8n’s flat pricing does not penalize message growth. As a directional guide based on published list prices (verify against current rates):
- Low volume (under 1,000 conversations/mo): savings are modest and may not justify the operational overhead of self-hosting.
- Mid volume (several thousand/mo): the flat-cost model usually begins to pay off clearly.
- High volume (tens of thousands/mo): the gap widens substantially as per-task fees scale and n8n’s cost stays flat.
The honest caveat: factor in the engineering time to deploy, secure, and monitor a self-hosted instance. For some small teams, a managed plan that costs more in subscription but less in operational time is the better total-cost decision.
Frequently Asked Questions
Is n8n free for WhatsApp chatbots?
n8n is free when self-hosted on your own server, with no per-execution charges and unlimited workflow runs. The only costs are your hosting infrastructure (roughly $5–$20/month on a VPS like Hetzner or DigitalOcean) and Meta’s WhatsApp Business API conversation fees, which Meta charges directly regardless of your automation tool.
n8n also offers a paid Cloud plan for teams that prefer managed hosting over self-deployment. For SMEs running high message volumes, self-hosting is typically the most economical option because a single VPS handles large message volumes for a flat fee, while per-task platforms bill incrementally as usage rises.
Can n8n handle WhatsApp Business templates?
n8n fully supports WhatsApp Business message templates through the official WhatsApp Business Cloud API node and HTTP request nodes. You can send pre-approved template messages — required for any conversation you initiate outside the 24-hour customer service window — by passing the template name, language code, and dynamic parameters.
WhatsApp templates fall into three categories Meta approves: Marketing, Utility, and Authentication. n8n handles all three, including variable substitution for order numbers, OTP codes, and customer names. Template approval times vary by category and content; check Meta’s documentation for current expectations. n8n lets you map dynamic data into approved templates without rebuilding the workflow each time a template changes.
How many messages can n8n process per second?
A self-hosted n8n instance on a modest two-core VPS handles a steady stream of WhatsApp messages, with throughput limited primarily by Meta’s WhatsApp Business API rate limits rather than n8n itself. Meta applies tiered messaging limits that scale up for verified, higher-quality businesses — consult Meta’s messaging-limits documentation for the tier that applies to your number.
n8n’s real bottleneck is rarely the engine — using queue mode with Redis and multiple worker nodes, a single instance scales horizontally to many concurrent executions. For most SMEs handling 1,000–10,000 daily conversations, a small server is more than adequate. The constraint that usually matters more is your AI model latency: an LLM call taking several hundred milliseconds per response dominates the timing far more than n8n’s node execution.
The takeaway: A self-hosted n8n WhatsApp chatbot can run for under ~$25/month, processes more messages per second than most SMEs will ever need, and supports every WhatsApp Business template category Meta offers — without paying per-task fees to a SaaS middleman. The trade-off is the operational responsibility of running the server yourself, which is worth weighing honestly against a managed alternative.
Sources & References
- n8n — Create WhatsApp Bot: A Low-Code Guide (+ Free Template)
- n8n — Building your first WhatsApp chatbot (workflow template 2465)
- n8n Community — How to create a simple WhatsApp chatbot with n8n
- Reddit r/n8n — n8n basics: Creating a WhatsApp chatbot with n8n
- Reddit r/n8n — No-code WhatsApp Bot — 15 mins Guide using n8n
Pricing, free-tier allowances, rate limits, and template-approval timing for the WhatsApp Business Platform are set by Meta and change periodically. Verify all figures against Meta’s official WhatsApp Business Platform documentation before making purchasing or compliance decisions. Published and last updated June 2026.
Note: This article is for general informational purposes; verify specifics against your own context.
