How to Build a WhatsApp Chatbot with n8n: Complete Setup Guide
How to build a WhatsApp chatbot with n8n is one of the highest-value automation skills a service business owner can learn right now. WhatsApp has over 2 billion active users globally and a 98 percent message open rate according to Salesforce research, compared to roughly 20 percent for email. When a lead sends your business a WhatsApp message and gets an instant, helpful, automated response at 10pm on a Sunday, you win the job before your competitor even sees the notification.
This guide covers the complete build. You will connect your WhatsApp Business account to n8n, configure a message trigger, build a response flow, add AI-powered replies using OpenAI, and wire the whole system into your CRM so every conversation becomes a tracked lead. Before getting into the steps, read about how AI automation works for service businesses to understand how this WhatsApp chatbot fits inside a complete lead capture and follow-up system.
Why WhatsApp Is the Most Underused Lead Channel for Service Businesses
Most service businesses have a website contact form, a phone number, and maybe a Facebook page. Almost none of them have an automated WhatsApp presence. That gap is the opportunity.
WhatsApp messages get read within three minutes on average. A lead who texts your WhatsApp number at 9pm expecting silence and instead gets an instant response that answers their question and asks for their address to schedule an estimate will book with you over every competitor who made them wait until morning. The businesses winning on WhatsApp right now are not the biggest ones. They are the ones who automated their response first.
The technical barrier that kept most small businesses off WhatsApp automation was the WhatsApp Business API, which historically required approved access through a Business Solution Provider and complex webhook configuration. That barrier has dropped significantly in the past two years. Meta now approves small business API access faster, and n8n makes the webhook and message handling straightforward without writing custom server code.
What You Need Before You Start
Have four things ready before opening n8n.
A WhatsApp Business account linked to a dedicated phone number. This number cannot be an existing personal WhatsApp number. Use a separate SIM or a virtual number from a provider like Twilio or RingCentral.
A Meta Developer account at developers.facebook.com. This is where you create the app that connects your WhatsApp Business account to the API.
A Meta Business Manager account verified with your business details. Meta requires business verification before granting full WhatsApp API access. The verification process takes one to three business days.
An n8n instance running either on n8n cloud or self-hosted. The instance needs a public HTTPS URL because WhatsApp requires a publicly accessible webhook endpoint to deliver messages. A locally running n8n instance on your laptop will not work for production. For self-hosting, a basic VPS with a domain and SSL certificate covers this requirement.
Step 1: Create a Meta App and Connect WhatsApp Business
Go to developers.facebook.com and click Create App. Select Business as the app type and follow the setup prompts. Once the app is created, scroll to the Add Products section on the app dashboard and click Set Up next to WhatsApp.
Meta will walk you through connecting a WhatsApp Business Account. You will either create a new one or link an existing WhatsApp Business account. Add the phone number you want to use for the chatbot under the Phone Numbers section. Meta assigns this number a Phone Number ID which you will need in a later step.
Inside the WhatsApp product settings, navigate to API Setup. Here you will find two critical pieces of information: your Temporary Access Token and your Phone Number ID. Copy both and keep them accessible. The Temporary Access Token expires after 24 hours during development. When you move to production you will generate a Permanent Access Token through the Meta System User settings inside Business Manager.
Step 2: Set Up the WhatsApp Webhook in n8n
Open your n8n instance and create a new workflow. Add a Webhook node as your trigger. Set the HTTP Method to POST and note the webhook URL that n8n generates. This URL is what you will paste into Meta's webhook configuration.
Go back to your Meta app dashboard, find the WhatsApp product, and click Webhooks. Click Subscribe to Fields and paste your n8n webhook URL into the Callback URL field. Meta requires a Verify Token during webhook setup. Set any string you choose as the Verify Token in Meta, then add a second step to your n8n webhook node that handles the verification challenge Meta sends when you first save the webhook.
To handle Meta's webhook verification, your n8n webhook needs to respond to a GET request by returning the hub.challenge parameter Meta sends. Add an IF node after your Webhook trigger that checks whether the incoming request is a GET verification request or a POST message event. For GET requests, return the hub.challenge value. For POST requests, route the flow into your message handling logic.
Subscribe to the messages field under Webhook Fields inside your Meta app. This tells Meta to send incoming WhatsApp messages to your n8n webhook URL.
Step 3: Parse Incoming WhatsApp Messages
When a WhatsApp user sends your business a message, Meta delivers a JSON payload to your webhook URL. The payload contains the sender's phone number, the message text, a message ID, and a timestamp among other fields.
Add a Set node after your webhook trigger to extract the fields you need. Map these values from the incoming payload:
The sender's phone number lives at entry[0].changes[0].value.messages[0].from. The message text lives at entry[0].changes[0].value.messages[0].text.body. The message ID lives at entry[0].changes[0].value.messages[0].id.
Rename these to clean variable names like senderPhone, messageText, and messageId in your Set node. Every subsequent node in the workflow will reference these clean variable names rather than the raw nested JSON path, which makes the workflow much easier to read and debug.
Step 4: Add AI-Powered Response Generation with OpenAI
A rule-based chatbot that matches keywords and returns fixed responses works for extremely simple use cases. For a service business handling real customer questions about pricing, availability, service areas, and job specifics, you need an AI layer that can handle the full range of natural language inputs a customer might send.
Add an OpenAI node after your Set node. Select the Chat Completion operation. Connect your OpenAI credentials. In the Messages field, build a system prompt that defines the chatbot's identity, knowledge, and behavior using the same structure covered in the AI agent guide. Identity first, behavioral rules second, knowledge block third, escalation instructions last.
Set the model to gpt-4o-mini for cost efficiency. At WhatsApp message volumes, GPT-4o-mini handles the task well and keeps your API costs under $5 per month for most small business usage levels.
Pass the messageText variable from your Set node into the user message field so the AI receives what the customer actually typed. The OpenAI node returns the AI's response as a string that you will pass into the WhatsApp reply step next.
According to the n8n official documentation, n8n has a native WhatsApp Business Cloud node that handles message sending without requiring manual HTTP requests, which simplifies the reply step significantly for users on n8n version 1.0 and above.
Step 5: Send the Reply Back to the Customer via WhatsApp
Add a WhatsApp Business Cloud node after your OpenAI node. Select the Send Message operation. Connect it using your Meta app credentials including the Phone Number ID and your Permanent Access Token.
Set the To field to the senderPhone variable from your Set node. Set the message body to the output from your OpenAI node. This closes the loop. The customer sends a message, n8n receives it, OpenAI generates a contextual response, and n8n sends that response back to the customer's WhatsApp within two to three seconds of their original message.
Test the flow by sending a message from a personal WhatsApp account to your business number. Watch the n8n execution panel to confirm each node fires correctly and the reply arrives on your test device.
Step 6: Add Lead Capture Logic Before Sending the Reply
An AI reply that answers the customer's question is valuable. An AI reply that also captures the customer's details and creates a CRM record simultaneously is what turns WhatsApp into a lead generation machine.
Add an IF node between your OpenAI node and your WhatsApp reply node. Configure it to check whether the conversation has reached a point where the AI has collected the customer's name and service interest. You can do this by adding a structured output instruction to your OpenAI system prompt that tells the model to include a JSON flag in its response when it has enough information to create a lead record.
When the IF node detects that the lead capture flag is present, branch the workflow to an HTTP Request node or a native CRM integration node that creates a new contact record. Pass the sender's phone number, name, and service interest as the contact fields. After creating the CRM record, continue to the WhatsApp reply node to send the customer's response.
For businesses using GoHighLevel, use the GoHighLevel API to create the contact and add it to a specific pipeline stage simultaneously. For businesses using a simpler setup, a Google Sheet append row node works as a lightweight lead log that your team checks daily. To see how this WhatsApp lead capture connects into a complete automation stack, the AI automation services for local businesses page covers what a full client deployment looks like end to end.
Step 7: Handle Message Types Beyond Plain Text
Customers send more than text messages on WhatsApp. They send voice notes, images of damage they want quoted, location pins, and document files. A production WhatsApp chatbot needs to handle these gracefully rather than throwing an error or going silent.
Add an IF node early in your workflow that checks the message type field from the incoming Meta payload. The type field is at entry[0].changes[0].value.messages[0].type. Route plain text messages through your main AI response flow. Route voice notes to a response that says your team will listen and follow up within a specific timeframe. Route images to a response that acknowledges receipt and asks for a description of what the customer needs.
For businesses that want voice note transcription, you can add a Whisper API call that transcribes the audio file and feeds the transcript into your OpenAI node as text input. This turns voice notes into fully handled AI conversations rather than dead ends.
Common Mistakes That Break WhatsApp Chatbots in Production
The most common mistake is using a Temporary Access Token in production. Temporary tokens expire after 24 hours and your chatbot goes silent without warning. Generate a Permanent System User Token through Meta Business Manager before going live and store it in n8n's credential manager.
The second most common mistake is not handling duplicate message delivery. Meta occasionally delivers the same webhook event twice. Add a deduplication check using the messageId variable from the incoming payload. Store processed message IDs in a simple Supabase table or Redis cache and check each incoming ID against the store before processing. If the ID already exists, skip the workflow execution.
The third mistake is building a single workflow that handles every message type, every conversation state, and every integration in one enormous canvas. Large single workflows become impossible to debug when something breaks. Split your WhatsApp automation into a main routing workflow and separate sub-workflows for each major function: lead capture, FAQ responses, appointment booking, and escalation.
For businesses that want the full WhatsApp automation system built without handling the technical setup, book a free audit with Octacs Systems and we will scope the build based on your message volume and CRM.
How Much Does a WhatsApp Chatbot on n8n Cost to Run
The cost breakdown for a WhatsApp chatbot on n8n has three components. n8n self-hosted on a basic VPS costs $10 to $20 per month. OpenAI API costs for a small business handling 300 WhatsApp conversations per month at an average of 200 tokens per reply run approximately $1 to $3 per month using GPT-4o-mini. WhatsApp Business API costs through Meta are free for the first 1,000 user-initiated conversations per month and $0.0147 per conversation after that for US numbers.
Total monthly cost for a WhatsApp chatbot handling up to 1,000 conversations sits between $11 and $23. That covers 24/7 automated responses, AI-powered replies, CRM lead capture, and full execution logging. For a professional website that drives more inbound WhatsApp inquiries to your chatbot, read about how professional websites help contractors get more leads as your next investment after this setup.
Frequently Asked Questions
Do I need a WhatsApp Business API account or will a regular WhatsApp Business app work?
You need the WhatsApp Business API to connect n8n and automate responses. The regular WhatsApp Business app on your phone does not expose a webhook or API endpoint, which means n8n has no way to receive incoming messages or send automated replies through it. The WhatsApp Business API is accessed through a Meta Developer app connected to your WhatsApp Business Account. Meta has made API access faster and simpler to obtain for small businesses over the past two years, and most straightforward business applications are approved within one to three business days of completing business verification.
Can the WhatsApp chatbot handle multiple customers simultaneously?
Yes. n8n processes each incoming webhook event as a separate workflow execution, and multiple executions run in parallel. If ten customers send messages within the same minute, n8n triggers ten separate workflow executions simultaneously and each one receives an independent AI response. There is no queue or delay caused by concurrent conversations. The only limit on simultaneous handling is your VPS server capacity, which a standard 2GB RAM instance handles comfortably at typical small business message volumes.
Will customers know they are talking to a chatbot and not a human?
This depends entirely on how you configure the system prompt. A well-written system prompt that gives the AI a realistic name, a natural conversational tone, and specific knowledge about your business produces responses that most customers do not identify as automated. For businesses that prefer transparency, adding a brief introduction line such as "Hi, I am Sarah, the automated assistant for [Business Name]" satisfies disclosure expectations without reducing response quality or customer satisfaction. Customers care more about getting a fast, accurate answer than about whether the responder is human.
What happens if a customer asks something the AI cannot answer?
Your system prompt should include explicit escalation instructions that tell the AI what to do when it encounters a question outside its knowledge. The standard approach is to have the AI acknowledge the question, tell the customer that a team member will follow up within a specific timeframe, and collect any additional contact information needed for the callback. The n8n workflow simultaneously sends an internal notification to your team via Slack or SMS containing the customer's question and contact details. The customer gets a clear response rather than silence, and your team gets an informed alert that requires a human reply.
How do I prevent the chatbot from sending incorrect pricing information?
Include an explicit rule in your system prompt that prohibits the AI from quoting specific prices without a site visit or assessment. Write the instruction directly: "Never quote a specific price. When a customer asks about cost, explain that pricing depends on the specific job requirements and offer to schedule a free estimate." This single instruction eliminates the most common source of chatbot errors for service businesses. You can still include price ranges in the knowledge block for general guidance, but the AI will frame them as estimates rather than commitments.
Can I use this same setup for Instagram DMs and Facebook Messenger?
Yes. Meta's Messenger Platform API and Instagram Messaging API use the same webhook architecture as WhatsApp Business API. Your n8n workflow structure, including the webhook trigger, message parsing, OpenAI response generation, and CRM integration, is largely identical across all three channels. The main differences are the API endpoints for sending replies and the payload structure of incoming messages. Building WhatsApp first and then adapting the workflow for Instagram and Facebook Messenger typically takes a few hours rather than rebuilding from scratch, because the core logic is already proven and working.
Share this post

Written by
Octacs Systems
Octacs Systems is a hybrid AI automation and digital solutions agency helping service businesses across the United States grow smarter. We build AI agents, workflow automation systems, and professional websites that generate real leads for plumbers, electricians, contractors, and local service businesses.
Related Articles

How to Build an AI Agent with n8n and OpenAI: Step-by-Step Guide
How to build an AI agent with n8n and OpenAI in 2026. Full step-by-step setup covering triggers, LLM nodes, memory, and CRM connection.

How to Build an AI Voice Receptionist with VAPI
VAPI lets you build an AI voice receptionist that answers calls, qualifies leads, and books appointments 24/7. Full setup guide inside.

GoHighLevel for Contractors: How to Automate Your Leads, Follow-Up, and Bookings in 2026
GoHighLevel for contractors handles your leads, bookings, and reviews automatically. Here is exactly how to set it up and what it does for your business

