# How to create a WhatsApp Chatbot on n8n? (Full Guide from Scratch)
Author: Manav Mahajan
Author URL: https://www.heltar.com/blogs/author/manav-mahajan
Published: 2025-10-18
Category: WhatsApp Chatbot
Category URL: https://www.heltar.com/blogs/category/whatsapp-chatbot
Tags: Automation, AI, n8n
Tag URLs: Automation (https://www.heltar.com/blogs/tag/automation), AI (https://www.heltar.com/blogs/tag/ai), n8n (https://www.heltar.com/blogs/tag/n8n)
URL: https://www.heltar.com/blogs/how-to-create-a-whatsapp-chatbot-on-n8n

There has been a lot of hype regarding n8n, and we have had multiple people come up to us and ask if **WhatsApp workflows** can be automated on n8n, and if yes, how exactly? We searched up the web but saw that there wasn't much **step-by-step** information available on the same. Hence, we built a workflow ourselves to show you how it's done.

This guide shows you how to build a working WhatsApp automation in n8n. You will set up **WhatsApp Business Cloud** from Meta, connect it to **n8n**, add an **AI agent** with memory, and **send replies back** to users on WhatsApp. We have added all steps in such a manner that they are easy to follow. Works on Windows, Mac, or Linux. No code needed.

## What you will build?

![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-19-001514-1760813198569-compressed.png)

- WhatsApp receiver that catches incoming WhatsApp messages.

- An AI agent that reads the message, keeps short chat memory, and generates a reply.

- WhatsApp sender that posts the reply back to the user.

- A simple safety check that only runs when a text body exists.

- A switch you can turn on to keep it running.


## What you need?

1. **n8n Cloud account**

   You can self host, but chat apps usually need SSL and clean public URLs. n8n Cloud saves you that setup.

2. **Meta Business access**

   A Facebook account with access to **business.facebook.com** and permission to create an app.

3. **WhatsApp Business Cloud**

   We will use Meta’s sandbox test number to start.

4. **Model access**

   OpenAI API key with a few dollars of credit for testing. You can swap to any other model later.


## How will the flow look like? (Quick Overview)

![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-19-001717-1760813258400-compressed.png)

1. WhatsApp message comes in.

2. n8n trigger fires and passes the text to an AI Agent node.

3. Memory node keeps a short window of the chat.

4. AI output goes to the WhatsApp Send node.

5. User sees the reply in WhatsApp.


You can add rules, databases, or tools later.

## Step 1 - Create a new workflow in n8n

- Log in to **n8n Cloud**& select **Create Workflow**.

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-234103-1760813324547-compressed.png)

- Click **New**, choose **Start from scratch**.

- Save the workflow with a clear name, for example: “WhatsApp Chatbot”.


## Step 2 - Add the WhatsApp trigger in n8n

- Click **+** then search for **WhatsApp Business Cloud**.

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-234150-1760813292525-compressed.png)

- Choose **Message**. This is the trigger node for incoming messages.

- Rename the node to **WhatsApp Trigger**. We will reference this name later.


### **Connect credentials for the trigger**

- Click **Select credential** then **Create new**.

- It asks for **Client ID** and **Client Secret**.


Get these from Meta:

01. Go to **business.facebook.com** and log in.

02. If you do not have a Business account, click **Create business** in **Business settings**.

03. In the left sidebar, under **Accounts**, click **Apps** then **Add** and **Create a new app**.

    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-234806-1760813655202-compressed.png)

04. Fill in **App Details** and On Use Cases, choose **Other**, then **Next**.

    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-234835-1760813764951-compressed.png)

    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235025-1760813885545-compressed.png)

05. For App type, choose **Business**, then **Next**.


    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235043-1760813919914-compressed.png)

06. Name the app, add your email, link it to your Business, and **Create app**.


    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235057-1760813958756-compressed.png)

07. Click **Set up** on **WhatsApp**.


    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235136-1760814009606-compressed.png)

08. Go to **App settings > Basic**.


    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235219-1760814040314-compressed.png)

09. Copy **App ID** to n8n **Client ID**


    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235239-1760814077422-compressed.png)

10. Click **Show** to copy **App secret** to n8n **Client Secret**.
11. **Save** in n8n. You should see “ **Connection tested successfully**".

    ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235312-1760814124231-compressed.png)


That’s your inbound WhatsApp trigger ready.

## Step 3 - Add the AI Agent in n8n

- Click **+**, search **Advanced AI**, choose **AI Agent**.

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235438-1760814167733-compressed.png)

- Click **Chat model** at the bottom.

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235525-1760814219356-compressed.png)

- In **Model provider**, pick **OpenAI**(you can change this later).

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235548-1760814295474-compressed.png)

- Click **Connect credential > Create new**.

- Paste your OpenAI **API key**, then **Save**.

- After you execute the previous nodes once, make the following changes. Select **Source for Prompt** as ' **Define Below**' and add the element ' **Body**' in the option **Prompt (User Message)**. Don't be worried if you do not see the option to do this right now, you could come back and change this later.


![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/agent-session-id-1760815032899-compressed.jpg)

Step 4 - Give the agent short-term memory

- Click **+**, search **Window Buffer/Simple Memory**.

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235627-1760814358197-compressed.png)

- Place it between the trigger and the AI Agent output path, or connect it as an input to the Agent, depending on your layout. The idea is the Agent reads and writes to this memory.


### **Set the Session ID to the user’s number**

![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-19-003947-1760814601053-compressed.png)

This lets the agent remember each user’s thread.

In **Window Buffer/Simple Memory**:

- Set **Session ID** to **Define below**.

- Click **Expression** and paste this:


```
{{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}

```

- Use the exact node name you set earlier, here it is ' **WhatsApp Trigger**'.

- Keep **Window size** small at first, for example **5** messages.


## Step 5 - Add WhatsApp sender in n8n

- Click **+**, search **WhatsApp Business Cloud**, choose **Send a message**.

  ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-19-000250-1760815160110-compressed.png)

- This node pushes replies back to the user.


### **Create credentials for the sender**

This time n8n asks for **Access token** and **Business account ID**.

Get them from Meta:

1. In your app’s left sidebar, click **WhatsApp > API Setup**.

   ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235826-1760815205847-compressed.png)

2. Use the provided **test phone number** for now.

   ![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-18-235857-1760815255799-compressed.png)

3. Click **Generate access token**. Copy it to n8n **Access token**.

4. Copy **WhatsApp Business Account ID** from the same page to n8n **Business account ID**.

5. **Save**. You should see “ **Connection tested successfully**”.


### **Configure the message**

- **Sender phone number**: pick the test number from the dropdown.

- **Recipient phone number**: enter **your phone number** with country code, no plus sign issues, for example 14155550123.

- **Text body**: put a placeholder like 'Message Received' for the first test.


## Step 6 - Wire it up

A clean first pass looks like:

```

[WhatsApp Message trigger] -> (optional IF check) -> [Window Buffer/ Simple Memory] -> [AI Agent] -> [WhatsApp Send]

```

To add the safety check:

- Click **+**, search **IF**.

- Set **Condition** to **String exists**.

- Drag the **body** field from the trigger output into the left side of the condition.

- True path goes to Memory then AI Agent then Send.

- False path can go to a **No-op** or stop.


## Step 7 - Test the inbound trigger

![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-19-001103-1760815629756-compressed.png)

- In the trigger node, click **Execute workflow**.

- Open WhatsApp on your phone or desktop.

- Start a chat to the **test number** shown in Meta’s API Setup page.

- Send a simple text, say “hello”.

- You should see the trigger fire in n8n.

- The sender node will post your placeholder text “ **Message Received**” back to you.


If that works, the pipe is healthy.

## Step 8 - Switch the reply to the AI output

![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/enabling-ai-output-1760815814165-compressed.jpg)

- Open the **WhatsApp Send** node.

- Clear the hardcoded `success`.

- Click into **Text body**, then from the **AI Agent** node, drag the **output** variable into the field.

- Save.


### Test again:

- Say “Hey”.

- You should get a real AI reply in WhatsApp.


### Try a follow up:

- Ask a second question, for example: “Which one would you recommend” after the agent lists options.

- Memory should keep context and give a sensible follow up.


![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-10-19-001514-1760815880197-compressed.png)

Step 9 - Activate the workflow

- Toggle the workflow from **Inactive** to **Active**.

- Now you do not need to click Test each time.

- New WhatsApp messages will flow through on their own.


## Troubleshooting!

- **No reply shows up**

  - Check **Executions** in n8n for errors.

  - Confirm the **IF** node is getting a **body** string.

  - Confirm the **Send** node has the right **Sender** and **Recipient** numbers.

  - Regenerate the **Access token** if it expired.
- **Memory not working**

  - Make sure your **Session ID** expression points at the user’s number and uses the exact trigger node name.

  - Keep **Window size** small at first.
- **Trigger never fires**

  - Recheck the WhatsApp **Message** trigger credential (App ID and App Secret).

  - Make sure you are messaging the **test number** shown in API Setup.

## Add common automations

You now have the core loop. Here are simple adds you can make in minutes:

1. **Keyword router**

   Add a **Switch** node after the trigger. Route “help”, “pricing”, “status”, etc, to different replies or subflows.

2. **Office hours**

   Add **Schedule** or a **Function** that checks time. If outside hours, send a polite note and log the lead.

3. **Lead logging**

   Add a **Google Sheets** or **Airtable** node. Save from, body, and timestamp for every message.

4. **Fallback to human**

   If AI confidence is low, send a handover message and push the chat to your help desk.

5. **Buttons and templates**

   Use WhatsApp **template messages** for menus, OTPs, and order updates. In n8n, choose a template in the send node and pass variables.


## Actually Deploying the bot full time?

1. **Long-lived token**

   The short token from API Setup expires. In Meta Business Settings, add a **System User**, assign it to your app, create a **Permanent token** with WhatsApp permissions, and store it in n8n. Rotate it on a schedule.

2. **Real phone number**

   Add a real business number in **WhatsApp > API Setup**. Complete display name and business verification if asked.

3. **24-hour window**

   WhatsApp allows free form replies within 24 hours of the user’s last message. After 24 hours, use **approved templates** to re-engage.

4. **Opt-in and content rules**

   Only message users who have opted in. Avoid restricted content. Keep logs.

5. **Secrets management**

   Store all tokens and keys in n8n credentials, not in plain text fields.

6. **Error alerts**

   Add an **Error workflow** in n8n that sends you an email or Slack message when executions fail.


## Is n8n-only WhatsApp automation feasible for real businesses?

Short answer, **No** for most teams. n8n is **great for a demo** or a **tiny workflow**, but day to day business needs are bigger and stricter.

### Why n8n alone breaks in practice?

- You need **many flows at once**, not one bot. Real chats fan out by keyword, menu, language, locale, and stage. Keeping dozens of n8n flows in sync is hard and fragile.

- You need **bulk and broadcast**. WhatsApp allows bulk only with approved templates and user opt-ins. Managing templates, approvals, variables, and opt-outs inside n8n quickly becomes messy.

- You must follow the **24-hour service window**. After 24 hours you can reply only with templates, managing and keeping track of this while automating with n8n is hard.

- Sales needs a shared inbox. **n8n is a workflow tool**, **not a team inbox**. You cannot assign chats, add notes, tag leads, or see who replied last without building a lot around it.

- You need **reporting and control**. Delivery, read rates, template failures, number quality, blocks, consent status, audit trails, and retries are all required. **Stitching this in n8n is heavy.**


## Why businesses need a provider to do this for them?

![](https://prod.superblogcdn.com/site_cuid_clnw4nrag2342701vpmufcj1n2w/images/screenshot-2025-07-18-183859-1759664048656-compressed.png)

Heltar is a **WhatsApp Business API provider** built for these needs.

- **[Shared inbox](https://www.heltar.com/blogs/how-to-set-up-shared-whatsapp-inbox-and-its-benefits-with-heltar-cm685r7ne003f33uy54gwp1jc)**, roles, and assignments so sales can work from one place.

- **[Automation](https://www.heltar.com/blogs/drag-and-drop-your-way-to-whatsapp-automation) inside the inbox**, plus quick setup for keywords, menus, and forms. You can create a WhatsApp chatbot using a **drag-and-drop**, **no-code chatbot builder**. Just **[one AI prompt](https://www.heltar.com/blogs/build-a-chatbot-using-an-ai-prompt)**, and you have your automation ready to be deployed. You can't get this luxury on n8n.

- **Template workflows** for approval, variables, and safe bulk sends. You [create templates and get them approved](https://www.heltar.com/blogs/whatsapp-message-templates-a-comprehensive-guide-to-approvals-and-best-practices-cm9l757xu009p14n5avpcsinb) within seconds, ready to be launched as part of bulk messaging campaigns.

- **24-hour window guardrails** that auto enforce message type rules.

- **Campaigns and segments** with schedules and rate control. [Schedule and Fire any campaign](https://www.heltar.com/blogs/how-to-send-bulk-messages-on-whatsapp-without-getting-banned2024-update-cm32nif0e00eo13fea49uaks0) in less than a minute, marketing made simple!

- **Live reports** for delivery, reads, failures, leads, and outcomes.

- **CRM and data hooks** without glue code.

- **Token and number hygiene** handled with alerts and retries.


## Best of both worlds

You can still use n8n for back-office logic, data cleaning, and custom steps, while Heltar handles WhatsApp delivery, inbox, teams, and compliance. That split keeps your flows flexible and your chat stack stable.

## Bottom line

If you are testing, n8n alone is fine. If you are running **sales or support**, use a WhatsApp Business API provider. Heltar gives you the inbox, automation, bulk, and controls you need, so your team focuses on closing leads, not babysitting bots.

Book a Demo


---
This blog is powered by Superblog. Visit https://superblog.ai to know more.
---

