How to Automate a WhatsApp Chatbot with n8n (No-Code Guide)
WhatsApp is the #1 messaging app in Morocco and across Africa. If your business isn't on WhatsApp, you're invisible. And if you're answering every message manually, you're burning hours that AI could handle. Here's how to build an AI-powered WhatsApp chatbot using n8n — no coding required.
Why WhatsApp Automation Matters
The numbers speak for themselves:
- 93% of Moroccans use WhatsApp daily
- Businesses lose 67% of leads that aren't responded to within 5 minutes
- AI chatbots reduce support costs by up to 80%
What You'll Build
By the end of this guide, you'll have a WhatsApp chatbot that:
- Responds to customer messages instantly, 24/7
- Answers FAQs using AI (powered by OpenAI)
- Captures leads and saves them to Google Sheets
- Escalates complex questions to a human
Prerequisites
- n8n account (free self-hosted or cloud plan)
- WhatsApp Business API access (via Twilio or Meta Business)
- OpenAI API key
- Google Sheets (for lead storage)
Step 1: Set Up WhatsApp Business API
Option A: Twilio (Easier)
- Create a Twilio account
- Enable WhatsApp Sandbox for testing
- Get your Account SID and Auth Token
- Create a Meta Business account
- Set up WhatsApp Business API
- Get your access token and phone number ID
- Add a "Webhook" trigger node
- Configure it to receive POST requests
- Set your WhatsApp provider to send messages to this webhook URL
- Add an "OpenAI" node
- Configure it with your API key
- Set the system prompt:
- Add an "HTTP Request" node
- Configure it to send the AI response back via WhatsApp API
- Add a "Google Sheets" node
- Save new contact name, phone, first message, and timestamp
- Send test messages to your WhatsApp number
- Verify AI responses are accurate and helpful
- Check that leads are being saved correctly
- Test the escalation flow
- 3x faster response times
- 60% reduction in support workload
- 25% increase in lead conversion (faster responses = more sales)
Option B: Meta Business API (Production)
Step 2: Create the n8n Workflow
Trigger: WhatsApp Message Received
Process: AI Response Generation
~~~
You are a helpful customer support assistant for [Your Business].
Answer questions about our products, pricing, and services.
If you don't know the answer, say "Let me connect you with our team"
and set escalate=true in your response.
Always respond in the customer's language (Arabic, French, or English).
~~~
Action: Send Response via WhatsApp
Save Lead: Google Sheets
Step 3: Add Smart Features
FAQ Knowledge Base
Create a Google Doc with your FAQs. Add a "Google Docs" node to retrieve this context before the AI node. This gives the AI accurate information about your specific business.
Language Detection
WhatsApp messages from Morocco come in Arabic, French, Darija, and English. Add a step that detects language and instructs the AI to respond in the same language.
Business Hours Logic
Add an "If" node to check if it's business hours. During hours, let the AI respond and notify your team. After hours, let the AI handle everything autonomously.
Step 4: Test and Deploy
Real Results
Businesses using this setup report:
Learn to Build This and More
212AY's AI Automation & Tools programme teaches you to build sophisticated automation workflows like this in 6 weeks. You'll master n8n, Make, and AI integration — skills that are in massive demand.