How to Build a WhatsApp Bot with n8n (Self-Hosted Bangladesh Guide)
SNBD Host Team
WhatsApp isn't just a messaging app in Bangladesh — it's how businesses communicate with customers, how delivery updates get sent, and how support tickets get resolved. If you're still responding to WhatsApp messages manually, you're leaving serious time on the table.
This guide walks you through building a WhatsApp bot using n8n, running on a self-hosted server. By the end, you'll have a bot that can respond to customer inquiries, send order confirmations, and forward urgent messages to your team — all automatically.
What You Need Before You Start
- A running n8n instance (see SNBD HOST's managed n8n hosting if you don't have one)
- A WhatsApp Business Account with the WhatsApp Business API enabled
- A Meta Developer account (free to create at developers.facebook.com)
- A verified phone number for the WhatsApp Business API
The WhatsApp Business API is free to use for the first 1,000 conversations per month. After that, Meta charges per conversation — check their current pricing on the Meta for Business site, as rates vary by country.
Step 1: Set Up the WhatsApp Business API
Go to the Meta Developer portal and create a new app. Select "Business" as the app type. Under the Products section, add "WhatsApp". You'll need to connect a WhatsApp Business Account — if you don't have one, you can create it during this process.
Once your app is created, navigate to WhatsApp > Getting Started. You'll see a test phone number already set up, which you can use immediately to send test messages. For production, you'll add your own phone number and complete the business verification process.
Note your Phone Number ID and WhatsApp Business Account ID — you'll need these in n8n.
Step 2: Create Your Access Token
In the Meta Developer portal, go to WhatsApp > Configuration. Generate a permanent access token. Keep this secure — it's what allows n8n to send messages on your behalf.
A better approach is to create a System User in your Meta Business Manager with the necessary permissions. System user tokens don't expire the way user tokens do, which means your automations won't break if someone's personal token expires.
Step 3: Configure the Webhook in n8n
In your n8n instance, create a new workflow. Add a Webhook node as the trigger. Set the method to POST and note the webhook URL that n8n generates — it will look something like https://your-n8n.snbdhost.com/webhook/whatsapp-incoming.
Go back to the Meta Developer portal, under WhatsApp > Configuration > Webhook. Paste your n8n webhook URL and set a verification token (any string you choose — remember it). Meta will send a GET request to verify the webhook. In n8n, add a second webhook node (or use an IF node after your first one) to handle this verification — it needs to respond with the hub.challenge parameter that Meta sends.
Verification Response Workflow
Your webhook trigger will receive two types of requests: verification requests from Meta (GET) and actual message events (POST). Use an IF node to check {{ $json.query["hub.mode"] === "subscribe" }}. If true, respond with {{ $json.query["hub.challenge"] }}. If false, proceed to your message-handling logic.
Step 4: Parse Incoming Messages
When a customer sends your WhatsApp number a message, Meta sends a JSON payload to your webhook. The structure is nested — the actual message text is buried inside the payload. Use an n8n Set node to extract what you need:
- Sender phone number:
{{ $json.body.entry[0].changes[0].value.messages[0].from }} - Message text:
{{ $json.body.entry[0].changes[0].value.messages[0].text.body }} - Message type:
{{ $json.body.entry[0].changes[0].value.messages[0].type }}
Store these in cleaner variable names using the Set node so downstream nodes are easier to read.
Step 5: Build Your Response Logic
This is where n8n's visual editor shines. You can build branching logic based on what the customer typed. A simple example for a Bangladesh e-commerce business:
- If the message contains "order status" → query your order database and reply with order details
- If the message contains "payment" or "bKash" → send a payment instruction message
- If the message contains "return" → send your returns policy and escalate to your support team
- Default → send a menu of options
Use n8n's IF and Switch nodes to build these branches. Each branch ends with an HTTP Request node that calls the WhatsApp API to send a response.
Step 6: Send WhatsApp Messages from n8n
To send a message, add an HTTP Request node configured as follows:
- Method: POST
- URL:
https://graph.facebook.com/v18.0/YOUR_PHONE_NUMBER_ID/messages - Authentication: Bearer Token — paste your access token
- Body (JSON):
{
"messaging_product": "whatsapp",
"to": "{{ $node['Extract Message'].json.from }}",
"type": "text",
"text": {
"body": "Your order #{{ $node['DB Query'].json.order_id }} is {{ $node['DB Query'].json.status }}. Expected delivery: {{ $node['DB Query'].json.delivery_date }}."
}
}
Practical Workflow Ideas for Bangladesh Businesses
Order Confirmation Automation
Connect n8n to your WooCommerce or custom order system. When a new order arrives, automatically send a WhatsApp confirmation to the customer with the order ID, items, total in BDT, and estimated delivery time. This alone can reduce "did my order go through?" support messages by 60-70%.
Delivery Update Notifications
If you use Pathao, Paperfly, or another Bangladeshi courier with an API, you can poll for status updates and push WhatsApp notifications when a parcel status changes. No more customers calling to ask where their package is.
Payment Verification
For businesses that accept bKash manual payments, you can build a workflow where customers send their bKash transaction ID via WhatsApp, n8n logs it to a Google Sheet or database, and your team gets a Telegram or email notification to verify and process the order.
Keeping Your Bot Running Reliably
A WhatsApp bot that goes down during business hours is worse than no bot. On SNBD HOST's n8n hosting, your instance runs on BDIX-connected servers with uptime monitoring included. If you're running n8n on your own VPS, make sure you have process management (PM2 or systemd) configured so n8n restarts automatically if the server reboots.
Also set up n8n's built-in error notifications — under Settings > Error Workflow, you can define a workflow that runs when any other workflow fails. A simple "send Telegram message on error" workflow can save you from silent failures you'd otherwise only discover when a customer complains.
What This Bot Cannot Do (Yet)
The WhatsApp Business API does not support initiating conversations with users who haven't messaged you first, unless you use pre-approved Message Templates. Template messages go through Meta's approval process (usually 24-48 hours) and must be non-promotional for the first contact. Plan your first-message flows around template messages for proactive outreach.
Next Steps
Once your basic bot is running, explore adding an AI layer — connecting your n8n WhatsApp flow to an OpenAI or Claude node that generates natural-language responses for complex inquiries. We cover this in detail in our n8n AI agent workflows guide.
Ready to get your n8n instance running? Check out SNBD HOST's n8n hosting plans starting from ৳499/month.