How to Build an AI WhatsApp Lead Follow-Up System in n8n (+ Ready-to-Deploy Template)
Learn how to automate your WhatsApp lead follow-up using n8n — and get a ready-to-deploy workflow template that installs in minutes.
How to Build an AI WhatsApp Lead Follow-Up System in n8n (+ Ready-to-Deploy Template)
If you've built lead pipelines before, you already know the problem: a lead fills out a form at 11pm on a Friday, your sales rep follows up Monday morning, and the deal is already dead. Speed-to-lead is the single biggest lever in conversion — studies consistently put the window at under 5 minutes before engagement probability drops off a cliff.
WhatsApp is where that problem gets solved. Open rates north of 90%, replies in minutes rather than days, and it runs on the phone your prospects already use all day. Pair it with n8n and OpenAI and you've got an always-on follow-up system that classifies intent, logs to your CRM, and responds contextually — without a human in the loop.
This post walks through the complete architecture for n8n WhatsApp automation for lead follow-up: how the workflow is structured, which nodes do what, the tricky parts that bite people in production, and how to set it up without burning a weekend.
Why WhatsApp Automation Beats Email for Lead Follow-Up
Email is fine for nurture sequences. It's terrible for the critical first 5 minutes.
WhatsApp's numbers are hard to argue with:
- 98% open rate vs ~22% for email
- Average reply time: 90 seconds vs 90 minutes for email
- No spam filter to dodge — messages arrive in the primary inbox every time
For small businesses — real estate agents, gyms, consultants, tradespeople — every missed follow-up is a missed sale. An n8n WhatsApp workflow running 24/7 means no lead goes cold because it came in on a Sunday afternoon.
The other advantage is bidirectional context. Unlike an SMS blast, WhatsApp supports conversation threads. Your automation can classify what the lead says ("I want pricing", "Not interested", "Book a call"), write that to the CRM, and send a different response for each case. That's what we're building.
The Architecture: How the Workflow Is Structured
Here's the node-by-node blueprint for a production WhatsApp lead follow-up n8n workflow:
Twilio Webhook → Normalize Payload → OpenAI Intent Classification → CRM Write → Switch Node → [Response Branch A / B / C / Fallback]
Trigger: Twilio Webhook Node
Twilio delivers inbound WhatsApp messages as HTTP POST requests to a URL you specify in your Twilio console. In n8n, you handle this with a Webhook node configured for POST, Respond Using Respond to Webhook Node mode.
The raw Twilio payload includes Body, From, To, MessageSid, AccountSid, and a handful of media fields. You need Respond Using Respond to Webhook Node mode — not the default "Immediately" response — because Twilio times out the webhook at 15 seconds and you need your response TwiML to land inside that window. More on this in the pitfalls section.
Step 1: Normalize the Payload
Twilio sends form-encoded data. Add a Set node immediately after the Webhook to extract and rename the fields you'll use downstream:
// Code node — Normalize Twilio Payload
const body = $input.first().json;
return [{
json: {
messageBody: body.Body,
fromNumber: body.From.replace('whatsapp:', ''),
toNumber: body.To.replace('whatsapp:', ''),
messageSid: body.MessageSid,
profileName: body.ProfileName || '',
receivedAt: new Date().toISOString(),
}
}];
Stripping the whatsapp: prefix from the numbers saves you from regex debt everywhere downstream.
Step 2: OpenAI Intent Classification
This is where the AI layer lives. Feed the normalized message body into an OpenAI node (or HTTP Request node hitting the Chat Completions API) with a system prompt that enforces structured output:
Model: gpt-4o-mini — fast enough to stay inside Twilio's 15s window, cheap enough to run on every inbound message without watching your cost metrics.
System prompt:
You are a lead intent classifier for a sales automation system.
Analyze the incoming WhatsApp message and classify the lead's intent.
Return JSON only, using this exact schema:
{
"intent": "pricing_request" | "book_appointment" | "not_interested" | "general_inquiry" | "existing_customer" | "unknown",
"urgency": "high" | "medium" | "low",
"sentiment": "positive" | "neutral" | "negative",
"summary": "one sentence summary of what they want"
}
Use response_format: { type: "json_object" } in your API call. This gives you guaranteed JSON back — no regex parsing, no try/catch around JSON.parse. The Code node downstream reads $json.intent directly.
Step 3: CRM Write
Before sending a response, write the lead record. Use an HTTP Request node or a native integration (HubSpot, Airtable, Google Sheets — whatever your client is using).
Write at minimum:
- Phone number
- Received timestamp
- Message body
- Classified intent
- Urgency
- MessageSid (critical for deduplication — more below)
Write before the response branch so the record exists regardless of which response path fires.
Step 4: Switch Node — Conditional Routing
An n8n Switch node reads {{ $json.intent }} and routes to different branches:
| Intent | Branch |
|---|---|
pricing_request | Send pricing info + CTA |
book_appointment | Send calendar link / booking flow |
not_interested | Log opt-out, send polite close |
general_inquiry | Send templated FAQ response |
unknown | Fallback — notify human via Slack/email |
Each branch has its own Respond to Webhook node that sends TwiML back to Twilio. If you want to also trigger an outbound message (outside the 15s response window), use the Twilio node in a separate execution path.
Subworkflow Pattern
For anything more complex than a basic response — multi-step appointment booking, lead scoring with external data, sending a PDF — break it into a subworkflow using the Execute Workflow node. Keep the main webhook workflow lean. The subworkflow handles the heavy logic asynchronously after the TwiML response is already delivered to Twilio.
AI WhatsApp Lead Follow-Up System
$29Ready-to-deploy n8n workflow. Import in 5 min. No rebuilding from scratch.
Setting Up the Workflow: What You Need
Prerequisites
- Twilio account with WhatsApp Sandbox enabled (or a production WhatsApp Business API number for live traffic)
- n8n instance with a public HTTPS URL — self-hosted or n8n Cloud
- OpenAI API key with access to
gpt-4o-mini - CRM access — API key or OAuth credentials for whatever you're writing to
Configuration Steps
Twilio side:
- In Twilio console → Messaging → Settings → WhatsApp Sandbox
- Set the "When a message comes in" webhook URL to your n8n Webhook node URL
- Set method to
HTTP POST
n8n side:
- Add your OpenAI API key to n8n credentials
- Add Twilio credentials (Account SID + Auth Token)
- Map your CRM credentials
- Set the Webhook node to
POST, path to something like/whatsapp-lead - Test with Twilio's "Try it Out" in sandbox mode before going live
Testing: Use Twilio sandbox — send "join [sandbox-keyword]" from your personal WhatsApp first, then test messages. Watch the n8n execution logs for the full chain.
Common Pitfalls (and How to Avoid Them)
These are the issues that show up in production that you won't find in the Twilio docs.
1. The 15-Second Timeout Problem
Twilio gives your webhook exactly 15 seconds to respond with TwiML. If your OpenAI call is slow (network latency, cold start), you'll miss the window and Twilio returns a 504 to the sender.
Fix: Respond immediately with an empty TwiML acknowledgment (<Response></Response>) using the Respond to Webhook node, then continue the rest of the workflow — CRM write, intent classification, outbound Twilio message — in a detached execution path. Use the Execute Workflow trigger pattern or n8n's built-in async execution.
2. Duplicate MessageSid Processing
Twilio will occasionally retry failed webhook deliveries. Without deduplication, you'll double-write to your CRM and double-respond to the lead.
Fix: Before the intent classification step, check your CRM (or a Redis/Airtable dedup table) for the MessageSid. If it exists, exit the workflow immediately. Write MessageSid on first processing, not after.
3. The 24-Hour Messaging Window
WhatsApp only allows you to send free-form messages within 24 hours of the customer's last message. After that, you need a pre-approved Message Template (MT) via the Business API.
Fix: If you're building follow-up sequences that send messages hours later, use Twilio's WhatsApp Template Message sending. Store the last inbound timestamp per contact and check it before deciding which send path to use.
4. JSON Parse Failures from OpenAI
Even with response_format: json_object, edge cases exist — long inputs, API instability, malformed escaping.
Fix: Wrap your Code node's JSON.parse in a try/catch and route failures to the unknown intent branch rather than crashing the workflow. Never let a parse error kill the execution.
5. Opt-Out Handling
WhatsApp has strict opt-out enforcement. If someone sends "STOP", you must stop. Twilio handles some of this automatically, but your CRM write step should flag opted-out contacts to prevent re-entry into the workflow.
Fix: Add a pre-check at the top of the workflow: if the incoming number has an opted_out: true flag in your CRM, exit immediately without responding.
6. Monolithic Workflow Anti-Pattern
Building everything — intent classification, CRM write, response, follow-up scheduling, Slack notifications — in a single n8n workflow creates a maintenance nightmare and makes debugging opaque.
Fix: Keep your main webhook workflow under 15 nodes. Break complex logic into named subworkflows called via Execute Workflow node. Each subworkflow has one job.
Get the Ready-to-Deploy Template
If you'd rather not spend a weekend wiring this together from scratch, the AI WhatsApp Lead Follow-Up System is a fully pre-built n8n workflow template that implements everything in this post.
What's included:
- Pre-wired Twilio webhook → normalize → OpenAI classification → CRM write → conditional response chain
- Async execution pattern (no Twilio timeout issues)
- MessageSid deduplication built in
- Opt-out handling
- Subworkflow architecture for easy customization
- Setup instructions for Twilio sandbox and production
Price: $29. Import it, add your credentials, and you're live in under an hour.
→ View the demo and get the template
Related articles
- How to Automate Appointment Booking with n8n — once you've got WhatsApp follow-up running, the next step is handling confirmations and reminders automatically.
- How to Build an AI Customer Support Chatbot in n8n — the same Twilio + OpenAI pattern, applied to inbound support tickets instead of lead follow-up.
- n8n Automation for Real Estate Agents — see how these WhatsApp workflows play out in a real estate context with 5 ready-to-deploy use cases.
- n8n Automation for South African Small Businesses — a practical guide to running WhatsApp automation in the South African market, with local pricing and load-shedding considerations.
- n8n Automation for Tradespeople and Contractors — how plumbers, electricians, and contractors use WhatsApp automation to stop losing jobs to a slow reply.
- n8n Automation for Cleaning and Home Services — how cleaning businesses auto-reply to WhatsApp quote requests and never lose a job to a slow response.
- n8n Automation for HR and Recruitment Agencies — how South African recruiters automate candidate follow-up, interview scheduling, and onboarding document chasing via WhatsApp.
- n8n Automation for Property Managers and Estate Agencies — how property managers use the same WhatsApp bot architecture to handle maintenance requests, tenant onboarding, and rent reminders automatically.
- n8n Automation for Accountants and Bookkeepers — how to build an invoice reminder bot from Xero webhook to WhatsApp message, plus FICA onboarding chasers and monthly report delivery sequences.
- n8n Automation for Hair Salons and Beauty Businesses — how ZA salon owners automate appointment bookings, new client follow-ups, and post-service product upsells via WhatsApp.
Built something with this? Questions about the architecture? The n8n community forum and r/n8n are solid resources — and if you're running into a specific pitfall not covered here, it's probably a topic for another post.
AI WhatsApp Lead Follow-Up System
$29Ready-to-deploy n8n workflow. Import in 5 min. No rebuilding from scratch.