An n8n WhatsApp Bot Tutorial Using the Official Cloud API

By Arezoo Mohammadzadegan July 23, 2026 9 min read
An n8n WhatsApp Bot Tutorial Using the Official Cloud API

This n8n WhatsApp bot tutorial shows how to build a bot that receives a customer’s message, answers it and hands the conversation to a person when it should. It uses the official WhatsApp Business Platform, often called the Cloud API, together with the WhatsApp nodes built into n8n. It also covers the parts most tutorials skip, such as which token to use in production, why a test URL can quietly break a live bot, how to give an AI agent memory for each customer, and the messaging and billing rules Meta applies. The WhatsApp side works the same way for a business in the UAE or in the US.

Illustration of a chat message passing through workflow steps and returning as a reply, with a side path to a person

Pick the official API, not a WhatsApp Web gateway

There are two ways to connect n8n to WhatsApp. The official route is Meta’s WhatsApp Business Platform, which n8n supports with a WhatsApp Trigger node and a WhatsApp Business Cloud node. The other route uses a gateway such as WAHA, which runs a WhatsApp Web session in a headless browser and logs in as a normal account. A freeCodeCamp tutorial on the WAHA approach is open about the trade-off. It says Meta does not officially endorse this for commercial use at scale, and that heavy messaging from one number can get that number banned.

WhatsApp’s own terms of service point the same way. They prohibit creating accounts through unauthorized or automated means, and they rule out bulk messaging, auto-messaging and any non-personal use of the service unless WhatsApp has authorized it. A bot that answers customers for a business all day is hard to square with that. A gateway can be fine for a personal experiment on a spare number, but it is a weak base for a business process, so the rest of this guide uses the official API.

What you need before you start

The n8n documentation for WhatsApp credentials lists three things on the Meta side. You need a Meta developer account, a Meta business portfolio (the old Business Manager) and a Meta business app with the WhatsApp product added. In the app’s basic settings you add a privacy policy URL and a terms of service URL, and then switch the app mode to Live.

You also need a phone number for the business. Meta’s rules for business phone numbers say the number must be owned by you, have a country and area code, and be able to receive voice calls or SMS. A number already in use with WhatsApp cannot be registered unless it is deleted from WhatsApp first, and once registered it cannot be used with the regular WhatsApp app. New business portfolios start with a cap of two registered numbers. Meta gives you a test number for building, so you can leave the choice of a real number until you are ready to go live.

On the n8n side, Meta has to reach your workflow over the internet, so your n8n instance needs a public address. n8n Cloud provides one. If you run n8n on your own server, you have to set that up yourself, and the hosting section of our comparison of n8n, Zapier and Make explains what self-hosting asks of you.

Set up the two credentials

n8n uses two different credentials for WhatsApp, which confuses many people the first time. According to the n8n documentation, the WhatsApp Business Cloud node, which sends messages, uses an access token and your WhatsApp Business Account ID. The WhatsApp Trigger node, which receives messages, uses OAuth2, with your Meta app’s App ID as the client ID and the App Secret as the client secret. You find the token and account ID in the Meta app dashboard under WhatsApp and then API Setup, and the App ID and secret under App settings and then Basic.

The token generated on the API Setup page is only for a quick test. Meta’s getting started guide says this temporary token expires quickly and is not suitable for development purposes. For a bot that has to keep running, create a system user in your Meta Business Settings, assign it your app and your WhatsApp account, and generate a token with the business_management, whatsapp_business_messaging and whatsapp_business_management permissions. That is the token to save in n8n. Make sure the business portfolio, the app and the system user all belong to your company and not to a freelancer’s personal account, so you keep control if the person who built the bot moves on.

Build the first workflow

Start with a bot that does one simple thing reliably before adding AI. The workflow below replies to every text message with a fixed answer.

  1. Add a WhatsApp Trigger node, select the OAuth2 credential and subscribe it to the Messages update. The trigger also offers updates such as template status and phone number quality, which you can ignore for now.
  2. Add an If node that only lets through items containing an incoming message. The same webhook also delivers status notifications, such as delivered and read, and you do not want to reply to those.
  3. Take two values from the incoming item, the sender’s phone number and the message text. Keep the sender’s number, because every later step needs it.
  4. Add a WhatsApp Business Cloud node with the Send operation, pick your sender number and set the recipient to the sender’s number from the previous step.
  5. Publish the workflow and send a message from your own phone to the test number.

One detail catches nearly everyone. The WhatsApp Trigger documentation warns that WhatsApp only allows a single webhook per app. n8n has a test URL and a production URL for each trigger, and switching between them overwrites the registered webhook, so only one of the two ever receives events. The documented workaround is to unpublish the workflow, test with the test URL and then publish again, which stops production traffic while you test. Once a bot is live, keeping a separate Meta app and test number for development saves you from that pause.

Person testing a chat bot reply on a phone with a workflow editor open on a laptop behind

Add an AI agent and give it memory for each customer

When the fixed reply works, replace it with n8n’s AI Agent node connected to a chat model, and pass the agent’s answer to the WhatsApp Business Cloud node. Two settings decide whether the bot can hold a sensible conversation.

The first is memory. The Simple Memory node stores chat history in the workflow under a session key, and its context window length sets how many previous interactions the agent takes into account. Use the sender’s phone number as the session key. Some tutorials key memory by the message ID, but every message has its own ID, so the agent would forget the conversation each time the customer writes. The same page warns that Simple Memory does not work in an active production workflow in queue mode, because n8n cannot guarantee that every call goes to the same worker. If you run n8n in queue mode, choose a memory node that stores history in a database instead.

💬

Need to generate WhatsApp QR Codes for your sales team?

Create instant click-to-chat QR codes with our free Business Generator.

Create WhatsApp QR
100% Free Tool by ArtinWebs

The second is what the agent is allowed to know. Write a system prompt that limits it to your own material, such as opening hours, delivery areas, products and policies, and tell it to say it will pass the question on when the answer is not there. Our guide to setting up an AI customer service agent explains how to decide which questions the agent should own and how to test it with real customer messages, and all of it applies to a WhatsApp bot. Not every step needs AI either. If customers mostly send an order number or choose from a short menu, a plain rule is cheaper and easier to test, which is the point of the section on when plain automation is enough in our guide to intelligent automation.

Hand the conversation to a person

Decide before launch which messages the bot must never handle alone. Complaints, refunds, questions about money owed and anyone who asks for a person are the usual ones. Send those to a member of your team with the full conversation, and tell the customer honestly when to expect a reply.

n8n has a built-in way to put a person in the loop. The WhatsApp Business Cloud node has a Send and Wait for Response operation that pauses the workflow until someone approves, answers with free text or fills in a short form, with an optional time limit on the wait. The documentation also says the node can be used as a human review step for AI Agent tool calls. In practice that means the agent asks someone on your team over WhatsApp before it runs an action you want checked, such as cancelling an order.

Stay inside WhatsApp’s messaging and billing rules

The rule that shapes every WhatsApp bot is the customer service window. Meta’s messaging documentation explains that when a user messages or calls you, a 24-hour window opens, and it resets each time they get in touch again. While it is open, your bot can send normal replies. Once it closes, you can only send pre-approved template messages. So a follow-up the next morning has to be an approved template, or it will not go out.

Messages your business starts, such as reminders, also need the person’s permission. Meta’s opt-in rules say a business must clearly state that the person is opting in, name the business they will receive messages from and comply with applicable law. Meta also recommends giving clear instructions for opting out of specific categories of messages. For customers in the UAE, the UAE government portal notes that Federal Decree-Law No. 45 of 2021 prohibits processing personal data without the owner’s consent, except in some cases. A simple way to let people start the chat themselves is a wa.me link or QR code on your website or packaging, which our free WhatsApp QR code generator creates.

Billing has changed recently, and many older tutorials are out of date. Meta’s pricing page says it charges per delivered message, based on the message category and the recipient’s country code. As of October 1, 2026, Meta charges again for service messages, which are the normal replies a bot sends inside the window. Each business phone number gets a free tier of 1,000 delivered service messages a month, and charging starts at the 1,001st. If there is no payment method on the account, Meta delivers service messages within the free tier but stops delivering them once it is used up. For a busy bot, add a payment method before launch, or replies can stop partway through the month.

Test before customers see it

The test number is enough to try the whole flow. Meta’s Cloud API get started page says you can add up to five recipient phone numbers to it. Ask a few colleagues to send messages that are as messy as real ones. These are the cases worth running.

  • A normal question the bot should answer from its material.
  • A question it must not answer, to confirm the handover works.
  • A photo, a voice note or a location, which your If node may not expect.
  • The same person writing again an hour later, to check that memory holds.
  • A message after more than a day of silence, to see how your follow-ups behave outside the window.

Two habits help once the bot is live. Keep a record of the message IDs you have already handled and skip any repeats, so the same webhook call never produces two replies. And set up an alert for failed runs, because a bot that silently stops answering does more harm than having no bot.

Know what it costs to run

A WhatsApp bot has three running costs, which are the n8n executions, the AI model calls on each message and Meta’s charges above the free tier. Our breakdown of how n8n counts executions shows how one workflow adds up. To judge whether the bot is worth it, the method in our guide on how to calculate automation ROI works well, as long as you count the time your team still spends on handovers as a cost.

Get help with your build

If you would rather not wire this up yourself, Artin builds n8n workflows and WhatsApp business agents for companies in the UAE and the US. Tell us which questions you want the bot to handle and we will tell you what is realistic, or book a free 30-minute strategy call.

Read next

A bot is only as good as the facts it is allowed to use and the moment it steps aside, and our guide to AI customer service agents for small businesses spends most of its time on exactly that. If you are still choosing a platform, the n8n, Zapier and Make comparison works through one workflow on all three. And if the question is whether a task needs AI at all, the intelligent automation guide lists what AI does badly.

Arezoo Mohammadzadegan
About the Author

Arezoo Mohammadzadegan

AI Programmer & Digital Marketing Strategist at ArtinWebs (A M H R MARKETING MANAGEMENT L.L.C). Specialist in Artificial Intelligence development, AI agent programming, n8n automation workflows, and digital transformation. Based in Dubai, UAE.