How to Automate WhatsApp with n8n

n8n WhatsApp Automation: How I Built Automated Messaging for My Clients

WhatsApp is the default communication channel in Latin America. Here in Chile, my clients’ customers do not check email regularly, they barely open SMS, but they read every single WhatsApp message within minutes. So when one of my startup clients asked me to automate their order notifications, customer support responses, and follow-up messages, WhatsApp was the only channel that made sense.

The challenge was building it without paying thousands for a dedicated WhatsApp marketing platform. Using n8n with the WhatsApp Business API, I built a complete messaging automation system that my client still runs today. In this guide, I will show you exactly how to do the same.

Why Automate WhatsApp with n8n?

WhatsApp Business API opens up a world of automation possibilities, but accessing it usually means either complex code or expensive third-party platforms. n8n bridges that gap perfectly.

Here is what makes n8n ideal for WhatsApp automation:

Direct API integration. n8n can call the WhatsApp Business API directly through HTTP Request nodes or through built-in WhatsApp nodes.
Template message support. You can send pre-approved message templates with dynamic variables.
Workflow flexibility. Trigger WhatsApp messages from any event: new orders, support tickets, scheduled reminders, or database changes.
Cost efficiency. You pay only for WhatsApp API messaging fees, not for a middleware platform markup.

For a deeper look at why n8n is my preferred automation tool, see my comprehensive n8n review.

What You Need to Get Started

WhatsApp Business API access requires a few more steps than most integrations. Here is the full list:

1. An n8n instance. Cloud or self-hosted. Get started with n8n here if you need an account.
2. A Meta Business Account. Create one at business.facebook.com if you do not have one.
3. WhatsApp Business API access. You can get this through Meta’s Cloud API (free tier available) or through a Business Solution Provider (BSP).
4. A verified phone number. This will be your WhatsApp Business number.
5. Approved message templates. WhatsApp requires pre-approved templates for business-initiated messages.

If you are new to n8n, I recommend starting with my beginner guide before diving into this integration.

Setting Up WhatsApp Business API Access

Option 1: Meta Cloud API (Recommended for Starting Out)

The easiest path is Meta’s Cloud API. Go to developers.facebook.com, create a new app, and select “Business” as the app type. Add the WhatsApp product to your app.

Meta gives you a test phone number and a temporary access token to start with. For production, you will need to:

1. Add your own business phone number.
2. Verify your business.
3. Generate a permanent access token (System User token).

Option 2: Using a BSP

Business Solution Providers like Twilio, MessageBird, or 360dialog handle the infrastructure for you. They provide their own APIs that you can call from n8n using HTTP Request nodes. The advantage is simpler setup. The disadvantage is additional cost per message.

Configuring Credentials in n8n

In n8n, you will use an HTTP Request node to interact with the WhatsApp Cloud API. Create a new credential of type “Header Auth” with:

Name: Authorization
Value: Bearer YOUR_PERMANENT_ACCESS_TOKEN


You will reuse this credential across all your WhatsApp workflow nodes.

Understanding WhatsApp Message Types

Before building workflows, you need to understand WhatsApp's messaging rules. This tripped me up when I first started.

Template Messages

These are pre-approved message formats that you can send to anyone, even if they have not messaged you first. You submit templates to Meta for approval, and they usually get reviewed within 24 hours.

Examples of template messages: order confirmations, shipping updates, appointment reminders.

Session Messages

Once a user messages your business number, a 24-hour "session window" opens. During this window, you can send free-form messages without using templates. This is where customer support conversations happen.

Key Rule

You cannot send free-form messages outside the 24-hour window. If the window has closed, you must use a pre-approved template to re-engage.

Building the Workflow: Automated Order Notifications

Let me walk you through the workflow that handles order notifications for my client's e-commerce store.

Workflow Overview

1. Trigger: New order placed (via webhook from the e-commerce platform).
2. Format Message: Prepare the WhatsApp message using an approved template.
3. Send WhatsApp Notification: Call the WhatsApp Cloud API to send the message.
4. Log to Database: Record the message status in PostgreSQL for tracking.
5. Handle Failures: Retry failed messages and alert the team.

Step 1: Receive the Order Webhook

Start with a Webhook node. Configure your e-commerce platform (WooCommerce, Shopify, or custom) to send order data to this webhook URL when a new order is placed.

Node: Webhook
Method: POST
Path: /order-notification
Response: Immediately (200 OK)


The webhook payload typically includes customer name, phone number, order ID, items, total amount, and estimated delivery date.

Step 2: Validate and Format the Phone Number

WhatsApp requires phone numbers in international format without the plus sign. Add a Function node to clean up the phone number:

const rawPhone = $input.first().json.customer_phone;

// Remove spaces, dashes, and plus sign
let phone = rawPhone.replace(/[\s\-\+\(\)]/g, '');

// Add country code if missing (56 for Chile)
if (phone.startsWith('9') && phone.length === 9) {
phone = '56' + phone;
}

return [{
json: {
...$input.first().json,
whatsappPhone: phone
}
}];

Step 3: Send the Template Message

Add an HTTP Request node to call the WhatsApp Cloud API. Assuming you have a template called "order_confirmation" approved, the request looks like this:

Node: HTTP Request
Method: POST
URL: https://graph.facebook.com/v18.0/YOUR_PHONE_NUMBER_ID/messages
Headers:
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
Body (JSON):
{
"messaging_product": "whatsapp",
"to": "{{ $json.whatsappPhone }}",
"type": "template",
"template": {
"name": "order_confirmation",
"language": { "code": "es" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "{{ $json.customer_name }}" },
{ "type": "text", "text": "{{ $json.order_id }}" },
{ "type": "text", "text": "${{ $json.order_total }}" },
{ "type": "text", "text": "{{ $json.estimated_delivery }}" }
]
}
]
}
}

Step 4: Log the Message to the Database

Add a PostgreSQL node (or MySQL, or Google Sheets if you prefer simplicity) to log every sent message:

Node: PostgreSQL
Operation: Insert
Table: whatsapp_messages
Columns:
order_id: {{ $json.order_id }}
phone: {{ $json.whatsappPhone }}
template: "order_confirmation"
status: {{ $node['Send WhatsApp'].json.messages[0].message_status }}
message_id: {{ $node['Send WhatsApp'].json.messages[0].id }}
sent_at: {{ $now.toISOString() }}

Step 5: Handle Failures

Add an IF node after the HTTP Request to check if the message was sent successfully. If the response status is not "accepted," route to an error handling branch:

IF: {{ $json.messages[0].message_status }} equals "accepted"
True → Continue to logging
False → Send Slack alert + Add to retry queue


For the retry queue, I use a separate workflow that runs every 15 minutes, checks the database for failed messages, and attempts to resend them up to 3 times.

Building a Customer Support Flow

The second major workflow I built handles incoming customer messages. When a customer replies to an order notification or sends a message to the business number, WhatsApp sends a webhook to n8n.

Setting Up the Incoming Message Webhook

In your Meta App dashboard, configure the Webhooks for WhatsApp. Set the callback URL to an n8n Webhook node and subscribe to "messages" events.

Node: Webhook
Method: POST
Path: /whatsapp-incoming

Processing Incoming Messages

Add a Function node to extract the message content:

const entry = $input.first().json.entry[0];
const change = entry.changes[0].value;

if (change.messages && change.messages.length > 0) {
const msg = change.messages[0];
return [{
json: {
from: msg.from,
messageType: msg.type,
text: msg.text?.body || '',
timestamp: msg.timestamp
}
}];
}

return [];

Auto-Respond Based on Keywords

Use a Switch node to route messages based on content:

Route 1: Text contains "estado" or "tracking" → Send order status
Route 2: Text contains "devolucion" or "return" → Send return instructions
Route 3: Text contains "hablar" or "agente" → Forward to human agent
Fallback: Send generic help menu


For the order status lookup, connect to your e-commerce database, find the order by phone number, and send back a session message with the current status.

Creating Message Templates

Here are the templates I have had approved for my clients. You create these in the Meta Business Manager under WhatsApp Manager, then Message Templates.

Order Confirmation (order_confirmation):

Hello {{1}}, your order #{{2}} has been confirmed.
Total: {{3}}
Estimated delivery: {{4}}
Thank you for your purchase!


Shipping Update (shipping_update):

Good news, {{1}}! Your order #{{2}} has been shipped.
Tracking number: {{3}}
Track it here: {{4}}


Appointment Reminder (appointment_reminder):

Hi {{1}}, this is a reminder about your appointment on {{2}} at {{3}}.
Reply YES to confirm or NO to reschedule.

Advanced Patterns I Use Daily

Scheduled Reminders

Use a Schedule Trigger to query your database for upcoming appointments or pending actions, then send WhatsApp reminders in bulk:

Schedule Trigger (every morning at 8 AM)
→ Query database for today's appointments
→ Split In Batches (10 per batch)
→ Wait 1 second (respect rate limits)
→ Send WhatsApp template
→ Log result

Two-Way Conversations with Context

Store conversation context in a database so your bot can maintain state across messages. When a customer says "yes" to confirm an appointment, the bot needs to know which appointment it is referring to:

Incoming message
→ Look up customer phone in conversation_state table
→ IF state exists: continue conversation flow
→ IF no state: start new conversation

Media Messages

You can send images, documents, and PDFs through the WhatsApp API. I use this for sending invoices:

HTTP Request:
{
"messaging_product": "whatsapp",
"to": "PHONE_NUMBER",
"type": "document",
"document": {
"link": "https://your-server.com/invoices/INV-123.pdf",
"caption": "Here is your invoice for order #123",
"filename": "invoice-123.pdf"
}
}

Cost Considerations

WhatsApp Business API is not free. Here is the pricing breakdown you should know:

- Business-initiated conversations (using templates): You pay per conversation, not per message. In Latin America, rates are roughly $0.04 to $0.08 USD per conversation.
- User-initiated conversations: When the customer messages first, rates are lower, around $0.02 to $0.03 USD.
- Free tier: Meta gives you 1,000 free service conversations per month.

The savings compared to SMS are significant in most Latin American countries, where SMS costs can be 5 to 10 times higher.

Troubleshooting Common Issues

Template rejected by Meta. Make sure your templates follow the guidelines: no promotional content in utility templates, no URL shorteners, and no excessive formatting. Keep them clear and transactional.

Phone number not verified. You need to verify your phone number via SMS or voice call during the setup process. Make sure the number is not already registered with WhatsApp Messenger.

Messages not arriving. Check that you are using the correct phone number ID (not the business ID or app ID) in the API URL. Also verify the recipient's number format.

Rate limits. New accounts start with a low messaging limit (250 unique customers per 24 hours). This increases as your quality rating improves.

FAQ

Can I use n8n WhatsApp automation with the regular WhatsApp app?

No, you cannot. WhatsApp automation requires the WhatsApp Business API, which is separate from the regular WhatsApp app and WhatsApp Business app. The regular app does not have an API. Some third-party services claim to automate the regular app, but this violates WhatsApp's terms of service and can get your number permanently banned. Always use the official Business API for automation, which you can access through Meta's Cloud API or a Business Solution Provider.

How many WhatsApp messages can I send per day with n8n?

The limit depends on your WhatsApp Business API tier, not on n8n. New accounts start at 250 unique customers per 24 hours. As your quality rating improves (customers are not reporting or blocking you), this increases to 1,000, then 10,000, then 100,000 per day. Meta evaluates your quality automatically. On the n8n side, there is no message limit. Just make sure to add small delays between API calls to respect WhatsApp's rate limits, which I typically set at about 1 second between messages.

Do I need a separate phone number for WhatsApp Business API?

Yes, the phone number you use for WhatsApp Business API cannot be simultaneously registered with the regular WhatsApp app or WhatsApp Business app. If you want to use an existing number, you will need to migrate it and you will lose access to the regular app on that number. I recommend getting a dedicated business number for API use. A landline number works too because WhatsApp can verify it via voice call. Many of my clients use a dedicated mobile SIM card specifically for this purpose.

Conclusion

Automating WhatsApp with n8n opened up a communication channel that actually reaches customers. In markets like Latin America, the difference between an email and a WhatsApp message can be a 10 percent open rate versus a 95 percent open rate.

The workflow I showed you today handles the complete order notification lifecycle: receiving the order, formatting the message, sending it via WhatsApp, logging the result, and handling failures gracefully. From here, you can expand into customer support automation, appointment reminders, and two-way conversation flows.

The key is to start simple. Get the order notification workflow running first, then layer on complexity as you learn how your customers interact with the bot.

Ready to get started? Set up your n8n instance here and connect your WhatsApp Business API. If you want to compare n8n with other automation options, check out my n8n vs Zapier comparison to see why I chose n8n for these types of integrations.

🚀 Ready to automate?

Start your free n8n trial today.

Try n8n Free →

Deja un comentario