Skip to content
TheAgent Ecosystem
AI Agents

Build a WhatsApp AI Agent With n8n and Twilio

Three nodes, one evening, and a bot that answers your inbox while you sleep

Muhammad Qasim HammadAI-assisted9 min read1,851 words

AI-drafted, reviewed by Muhammad Qasim Hammad on June 11, 2026. See our AI disclosure.

WhatsApp AI agent message flow: customer texts, Twilio webhook fires, n8n AI agent replies in seconds
Table of contents
  1. What Is a WhatsApp AI Agent, and What Can It Actually Do?
  2. Why Start in the Twilio WhatsApp Sandbox?
  3. How Much Does a WhatsApp AI Agent Cost to Run?
  4. How Do You Build It in n8n? (Three Nodes)
  5. Node 1: Webhook
  6. Node 2: AI Agent
  7. Node 3: Twilio Send
  8. When Are You Ready to Go Live?
  9. Where Can This Go Wrong?
  10. What Should You Set Up This Weekend?

The same four questions land in your WhatsApp every day: hours, price, availability, location. A WhatsApp AI agent answers those repeat questions the moment they arrive, day or night, so you stop living in the chat.

Each interruption costs you context. You drop what you're doing, type the same reply you typed yesterday, and get back to work two minutes later. Multiply that by 20 messages a day and you've lost an hour. None of those messages needed you specifically. They just needed an answer.

This post walks through the full build: a Webhook node, an AI Agent node running Claude, and a Twilio node that fires the reply back. You can test the whole thing for free tonight. Going live takes a bit more setup, and this post is honest about that too.

What Is a WhatsApp AI Agent, and What Can It Actually Do?#

A WhatsApp AI agent receives customer messages through the WhatsApp Business API, answers them with a language model, and sends the reply without you touching the app. It works inside the 24-hour customer-service window, so it handles the questions customers start. It is not a payments bot, a booking system, or a replacement for you.

The practical use case for a solopreneur is narrow and useful: deflect the repeat questions. "Are you open Saturday?" "What does your starter package cost?" "Do you work with clients in Berlin?" The agent handles those instantly. Anything involving money, a firm commitment, or a complaint goes to a human. That framing also keeps the agent safe.

This is the same Webhook -> AI Agent pattern I already run for email triage with Claude in n8n. WhatsApp is just a new front door onto an identical shape.

Why Start in the Twilio WhatsApp Sandbox?#

The Twilio WhatsApp Sandbox is free, requires no Meta Business verification, no registered sender, and no purchased phone number. You activate it in the Twilio Console under Try WhatsApp, accept the terms, and click Confirm. You get a shared sandbox number (+1 415 523 8886) and a unique join code.

Anyone you want to test with texts join <your-sandbox-code> to that number. The sandbox confirms they are in. I pasted the n8n Webhook URL into the "When a message comes in" field, texted "what are your hours?" from my personal phone, and got a Claude reply back in about four seconds. No inbox, no app to install.

The sandbox has real limits you should know before you count on it:

  • Test numbers only: you can only exchange messages with numbers that have joined your sandbox.
  • The session expires three days after joining. A tester must re-join after that.
  • The sandbox sends one message every three seconds maximum.
  • Only three pre-approved templates exist for business-initiated messages.

For building and verifying the workflow, these limits are fine. For serving real customers, you need a registered sender (covered under "When are you ready to go live?").

Checklist of Twilio WhatsApp Sandbox limits including 3-day session, test-only numbers, and rate limits for n8n testing.Know these limits before you test the sandbox.

How Much Does a WhatsApp AI Agent Cost to Run?#

At 1,000 customer replies a month, your Twilio bill is exactly $5: 1,000 x $0.005 = $5. Meta charges nothing for free-form replies inside the 24-hour window. Add number rental (around $1.15/month for a local number in production) and your Claude API cost, and you have the full picture.

Here is the breakdown by message type, pulled from Twilio's WhatsApp pricing page:

Message typeMeta feeTwilio feeWhen it applies
Customer reply (free-form, in window)$0.00$0.005You reply within 24h of customer message
Utility template (in window)$0.00$0.005Structured reply inside the window
Utility template (outside window)$0.0034$0.005You initiate after 24h expires
Marketing templateVaries by country$0.005Promotional messages you start
Inbound message (customer to you)$0.00$0.005Every message that arrives

The reply agent in this guide operates entirely in row one. If you get 1,000 customer questions a month and reply to each once, total Twilio cost is $5. That is the honest ceiling, not a marketing headline.

To keep your Claude API bill predictable as this scales, see the Claude API cost control guide.

Stat cards showing $0.005 per reply, $0 Meta fee in window, 3-day sandbox session, and 1 message per 3 seconds sandbox limit.The four numbers that define this build's cost and limits. Flowchart of a WhatsApp AI agent message round trip: Twilio receives the message, n8n triggers, Claude replies, test on the sandbox, then go liveHow one WhatsApp message travels through Twilio, n8n, and Claude and back.

How Do You Build It in n8n? (Three Nodes)#

Three nodes handle the entire flow: a Webhook that catches the inbound message, an AI Agent that generates the reply, and a Twilio node that sends it back. Build it on n8n self-hosted on a $5/month VPS (see the self-host n8n VPS setup guide) or on n8n Cloud.

Node 1: Webhook#

Add a Webhook node. Set HTTP Method to POST. Copy the Production URL. Paste it into the "When a message comes in" field in your Twilio sandbox settings. When Twilio receives a WhatsApp message, it POSTs the message body and the sender's number to this URL. The key fields you'll use downstream are Body (the message text) and From (the customer's WhatsApp number in whatsapp:+15551234567 format).

Node 2: AI Agent#

Add an AI Agent node (LangChain-based) connected to the Webhook. Attach a Claude model. For FAQ replies, Claude Haiku 4.5 is fast and cheap; upgrade to Claude Sonnet 4.6 if you need more nuanced answers. Write a short system prompt:

code
You are the assistant for [Business Name]. You answer questions about [what you do, your hours, your pricing range].
If a customer asks about payments, orders, or anything requiring a firm commitment, say: "Great question - I'll have a real person follow up with you shortly."
Keep replies under 3 sentences. Be friendly and specific.

Map the Webhook's Body field into the agent's user input.

Node 3: Twilio Send#

Add a Twilio node after the AI Agent. Set Resource to SMS and Operation to Send. Turn on the "To Whatsapp" toggle. n8n automatically prefixes whatsapp: on both the From and To numbers.

  • From: whatsapp:+14155238886 (sandbox number) or your registered production number later.
  • To: the From value from the Webhook (the customer's number).
  • Message: the AI Agent's output text.

The Webhook returns an immediate HTTP 200 to Twilio (preventing a timeout), while the AI Agent and Twilio node run asynchronously. Twilio's inbound webhook has a short response window, so this async pattern gives the AI time to generate a good reply without racing a clock.

This is the same architecture described in the lead follow-up automation guide: a webhook front door with an async send at the back.

Step-by-step diagram showing how to build a WhatsApp AI agent with n8n using Webhook, AI Agent, and Twilio nodes.The full build fits three n8n nodes.

When Are You Ready to Go Live?#

Going live means leaving the sandbox and connecting a registered WhatsApp sender. You need a Twilio phone number (local numbers start at about $1.15/month) and Meta Business verification. Meta reviews your business display name, website, and use case before approving the sender.

Once approved, swap the sandbox number for your registered number in the Twilio node's From field. Everything else in the workflow stays identical.

The key limit to carry into production: the agent can reply freely to any customer who messages first, inside the 24-hour window. It cannot start a new conversation after that window closes without using a paid template. If a customer asks a question on Monday and you want to follow up on Wednesday, that is a template message, not a free reply.

Comparison table of Twilio WhatsApp Sandbox versus a registered production sender across setup, cost, reach, and best use case.Choose sandbox to test, production to serve real customers.

Where Can This Go Wrong?#

The biggest risk is an agent that overcommits. If the system prompt does not clearly fence what the agent can and cannot do, Claude will answer confidently about things it should not touch: refund timelines, specific prices that change, stock availability, delivery dates.

A few other failure points worth knowing:

  • Hallucination guardrails. The agent only knows what is in its system prompt. Give it your actual hours, your actual price ranges, your actual service areas. Do not leave it to infer.
  • The 24-hour window. If a customer messages and your agent doesn't reply within 24 hours (n8n downtime, for example), the window closes. You'll need a template to re-engage.
  • Sandbox rate limits. During testing, one message every three seconds means rapid-fire test sequences will queue or drop. Test one message at a time.
  • Number formatting. Twilio passes the From number with the whatsapp: prefix already attached. If you map it incorrectly into the Twilio send node, the message will fail. Check the execution log first.

See the n8n vs Make vs Zapier cost comparison if you are weighing whether n8n is the right automation layer for this.

What Should You Set Up This Weekend?#

Start with the sandbox build tonight: it takes one evening and confirms the whole concept with your own phone before you spend a single dollar. Then spend a second short session tightening the system prompt against the real questions you get, so the replies sound like you and stay accurate.

Once the replies look right, open a Twilio account, register a WhatsApp sender, complete Meta Business verification, and swap the number. The workflow does not change. Add the human-handoff IF branch before you point any real customer at it.

The three-node pattern here is reusable. The same Webhook -> AI Agent -> send shape powers the email triage agent and can extend to SMS, Slack, or any channel Twilio or n8n touches. Build it once, move it where the questions are.

Frequently asked questions

Is the Twilio WhatsApp Sandbox free?
Yes. The Twilio WhatsApp Sandbox costs nothing to activate or use for testing. You only pay when sending messages on a production number ($0.005 per message). The sandbox does not require a purchased phone number.
How much does a WhatsApp AI agent cost to run?
Twilio charges $0.005 per outbound message. Inside the 24-hour customer-service window, Meta adds no fee on free-form replies. At 1,000 replies a month, your Twilio bill is 1,000 x $0.005 = $5, plus the number rental (around $1.15/month for a local number) and your AI model API cost.
Do I need Meta Business verification to test?
No. The Twilio WhatsApp Sandbox lets you test without Meta Business verification or a registered sender. You join by texting a code to the shared sandbox number and can test fully from your own phone.
Can n8n send WhatsApp messages through Twilio?
Yes. n8n has a built-in Twilio node. Set the resource to SMS, the operation to Send, and turn on the To Whatsapp option. n8n automatically prefixes the whatsapp: identifier on the From and To numbers.
What is the 24-hour customer service window?
Once a customer sends you a WhatsApp message, WhatsApp opens a 24-hour window in which you can reply with free-form messages at no Meta fee. Outside that window, you need a paid template to initiate contact.
Can the agent message customers first?
Not for free. Starting a conversation outside the 24-hour window requires a pre-approved WhatsApp template, and Meta charges a per-message fee for it. The agent in this guide only replies to messages customers send first.

Sources

Primary references and vendor documentation used while drafting and reviewing this article.

  1. Twilio WhatsApp Sandbox Documentation
  2. Twilio WhatsApp Pricing
  3. Twilio Messaging Pricing
  4. n8n Webhook Node Documentation
  5. n8n AI Agent Node Documentation
  6. n8n Twilio Node Documentation

Related reading