# API via HTTP in n8n Cloud

This guide shows you how to integrate Whapi.Cloud with n8n Cloud using simple HTTP requests.\
You'll learn how to receive WhatsApp messages via webhooks, send text messages, create groups, and automate other WhatsApp actions directly from your n8n Cloud workflows.

{% hint style="success" %}
**Note:** This guide covers integration with Whapi.Cloud via HTTP requests in the **n8n Cloud** version.\
If you're using **Self-Hosted n8n**, we offer a dedicated custom module for easier integration.\
Learn more here → [custom-node-for-n8n](https://support.whapi.cloud/help-desk/integrations/custom-node-for-n8n "mention")
{% endhint %}

***

To follow this guide, you'll need:

* An active **Whapi.Cloud** account and your channel's **API Token** (available in your [Whapi.Cloud dashboard](https://panel.whapi.cloud/dashboard)). For more details on how to obtain a token, please refer to the article: [getting-started](https://support.whapi.cloud/help-desk/getting-started "mention")
* An active **n8n Cloud** account with permission to create workflows.

Make sure both accounts are properly set up before proceeding.

{% embed url="<https://youtu.be/XJd41xmXoJM>" %}

***

{% hint style="success" %}
Use our demo bot template from the official n8n website to get started quickly: <https://n8n.io/workflows/12722-create-an-ai-chatbot-for-whatsapp-with-whapicloud-and-openai-gpt-35/>
{% endhint %}

### Step 1. Setting up Webhook in n8n

{% stepper %}
{% step %}
In your n8n Cloud workflow, add a new **Webhook** node.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FEZHzg7SfVatWEUUnrNvT%2Fimage.png?alt=media&#x26;token=37f549bc-0ffd-427e-bf1e-56cf2d201d68" alt="Setting up Webhook in n8n" width="196"><figcaption><p>Setting up Webhook in n8n</p></figcaption></figure>
{% endstep %}

{% step %}
Configure the node by selecting **POST** as the HTTP method. Copy the generated Webhook URL provided by n8n.&#x20;

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FJOnUx1cAT4hYF0vGNMiW%2Fimage.png?alt=media&#x26;token=1c16a9df-20c9-4a8b-9277-0a860aa74d20" alt="" width="194"><figcaption><p>Simple webhook configuration in n8n</p></figcaption></figure>

{% endstep %}

{% step %}
Go to your Whapi.Cloud channel settings and paste the copied URL into the webhook URL field. Enable the events you wish to receive (e.g., incoming messages).

{% hint style="info" %}
Attention!

Webhooks in n8n only work during active listening:

* If you are using the Test URL, you must click "Listen for test event" – in this mode, the webhook only works for a limited time.
* If you are using the Production URL, the workflow must be activated (set to the Active state).

If the workflow is not running, the webhook will not accept requests, and clicking "Check Webhook" in the Whapi panel will result in a connection error message.
{% endhint %}

<div><figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FzsQnqei5smXbub9ZJP8w%2Fsettings-whapi.png?alt=media&#x26;token=a924e301-59a8-43cf-b6a3-cbe056ff1b20" alt="" width="375"><figcaption><p>Channel settings on Whapi.Cloud</p></figcaption></figure> <figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FwHUPA1HZRwDBub2uPJSD%2Fimage.png?alt=media&#x26;token=3b41b1f8-d70c-4b2f-b187-c39a830d31f7" alt="" width="273"><figcaption><p>Set specific events in the webhook settings.</p></figcaption></figure></div>
{% endstep %}
{% endstepper %}

Your Whapi.Cloud events (new messages) will now trigger this Webhook node in n8n.

### Step 2: Receiving Messages in n8n

* Ensure your Webhook node in n8n is active and configured for **POST** requests.\
  Before sending a test message, make sure the workflow is running — either in **Test** mode (click **Listen for test event**) or **activated** in **Production** mode.
* Send a test message to your connected WhatsApp number.
* The Webhook node in n8n will capture the incoming message instantly.
* Inspect the received JSON payload to familiarize yourself with its structure for further workflow automation.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FM3LK0ZdsJRp8vB79oDVb%2Fn8n2-1.png?alt=media&#x26;token=af190c04-cf00-42f5-9ddf-f42878f2c501" alt=""><figcaption><p>Example JSON payload</p></figcaption></figure>

You can view all examples of incoming callbacks here: [incoming-webhooks-format](https://support.whapi.cloud/help-desk/receiving/webhooks/incoming-webhooks-format "mention")

Example JSON payload:

```json
{
  "messages": [
    {
      "id": "p.w30M7fgwWD4XwHu.g4CA-gBgTwl0rVw",
      "from_me": false, // Please note this parameter, which allows you to understand whether the message is incoming or outgoing. In the future, we will filter webhooks based on this parameter.
      "type": "text",
      "chat_id": "919984351847@s.whatsapp.net",
      "timestamp": 1712995245,
      "source": "mobile",
      "text": {
        "body": "Hello world"
      },
      "from": "919984351847",
      "from_name": "Gerald"
    }
  ],
  "event": {
    "type": "messages",
    "event": "post"
  },
  "channel_id": "MANTIS-M72HC"
}
```

### Step 3: Sending Messages from n8n

{% stepper %}
{% step %}
Add an **HTTP Request** node to your n8n workflow.

To do this, select Core, then HTTP Request.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FumtqqotuPFJy2qAOuNpU%2Fn8n4-1.png?alt=media&#x26;token=8a2bb3b1-87c2-4521-9cf8-0c6a4a5cfc58" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Configure the HTTP Request node as follows:

You will need to use the correct request configuration from the Whapi.Cloud documentation. Examples and convenient documentation with examples can be found here: [API Docs](https://whapi.readme.io/reference/sendmessagetext)

* **HTTP Method:** `POST`
* **URL:** `https://gate.whapi.cloud/messages/text`

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2F21h3iT0Rx0LYiCX4Bvy8%2Fn8n3-1.png?alt=media&#x26;token=f6d1dd46-d312-40dc-a8e8-2907b68f352f" alt="" width="563"><figcaption><p>Information for the request can be easily obtained from our docs.</p></figcaption></figure>
{% endstep %}

{% step %}
Authentication:

To authorize, you will need to select **Bearer Auth** in the *Credential Type* field. After that, enter and save your channel token from Whapi.Cloud.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FbAkVw3zWhw7VjObGoLT0%2Fimage.png?alt=media&#x26;token=8bc30407-6f5a-4e3a-91dd-30f1f1488832" alt="" width="263"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
In the **Body** section, select **RAW / JSON** and enter:

```json
{
  "to": "recipient_number",
  "body": "Hello from n8n and Whapi.Cloud!"
}
```

Replace `"recipient_number"` with the recipient’s WhatsApp number (international format, no `+`).

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FAETl00BeL24rHGNxdXLR%2Fimage.png?alt=media&#x26;token=e0ffeab5-6c98-40aa-a0c3-69b768e660a8" alt=""><figcaption><p>Parameters for sending a message in WhatsApp</p></figcaption></figure>

You can specify either the recipient's number in international format or the chat ID. It doesn't matter which one you use. For more information about what a chat ID is, see: [chat-id.-what-is-it-and-how-to-get-it](https://support.whapi.cloud/help-desk/faq/chat-id.-what-is-it-and-how-to-get-it "mention")
{% endstep %}
{% endstepper %}

***

### Filtering Incoming Messages to Build a WhatsApp Bot

So far, we've covered the basic setup of connecting the WhatsApp API to n8n, allowing you to receive incoming messages and send messages to any number — including groups and channels.

Now let’s look at a common use case: building an automated bot in WhatsApp. In this scenario, you typically want the bot to respond only to **incoming** messages, and ignore outgoing ones to avoid loops.

To achieve this, you’ll need to filter incoming webhooks. Let’s add a **Filter** node to your workflow.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FSN7pDkomIrMjn6QxCQou%2Fn8n6-1.png?alt=media&#x26;token=5cb5dbed-d33e-4e72-b794-764b56c7db66" alt=""><figcaption></figcaption></figure>

Your goal is to distinguish incoming messages from outgoing ones. This can be done by checking the `from_me` parameter in the webhook payload:

* `from_me = true` → the message was sent **by you** (outgoing)
* `from_me = false` → the message was received **from the user** (incoming)

By filtering for `from_me = false`, your bot will respond only to actual user messages and won’t react to its own replies.\
Make sure to set the data type to **Boolean** when configuring the filter, as shown in the example below.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FjUkmTC39zDsR7BKQsaWJ%2Fn8n5-1.png?alt=media&#x26;token=737dabf3-5c3b-4726-bf8b-c9e11cd9ae7e" alt=""><figcaption></figcaption></figure>

***

### Creating a WhatsApp Group via n8n

Now let’s walk through how to create a new WhatsApp group and send a message to it - along the way, we’ll highlight a few important details.

To create a group, use the **Create Group** endpoint. You can find the full documentation here:\
👉 <https://whapi.readme.io/reference/creategroup>

In n8n, add an **HTTP Request** node:

* Set the method to **POST**
* URL: `https://gate.whapi.cloud/groups`
* Add your channel's **Authorization Bearer Token** to the headers

Now let’s review the required parameters:

* `subject`: the name of the group
* `participants`: an array of phone numbers (as strings) to be added to the group during creation

The easiest way to pass the participants array is by selecting **“Specify Body → Using JSON”** in the HTTP node. This allows you to enter the full JSON payload directly in the body.\
(There is also a more advanced method using a Set node to build the array dynamically, but we won’t cover that here.)

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FPI3jVWMePWDEFDZzucW6%2Fn8n7-1.png?alt=media&#x26;token=3ffad77a-2320-44e8-951e-81da8b93cb71" alt="" width="260"><figcaption></figcaption></figure>

You can copy a ready-to-use JSON body directly from our documentation: <https://whapi.readme.io/reference/creategroup>. This helps avoid issues with extra line breaks or formatting.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2FL45iLAS8ueGtaA6CKZUE%2Fn8n-9-1.png?alt=media&#x26;token=e61733a8-123b-425f-8986-e3de792414e6" alt="" width="375"><figcaption><p>This makes it easier to get the correct JSON.</p></figcaption></figure>

After sending the request, the response will include full details of the newly created group.\
Make sure to **save the `group_id`**, as you’ll need it later in the `to` parameter when sending messages to the group.

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2F7RA3RsLqRd3oRiW4jPTY%2Fn8n8-1.png?alt=media&#x26;token=11a4ccc2-95af-4560-8140-66e392eb03f1" alt="" width="213"><figcaption><p>Use group_id to send messages</p></figcaption></figure>

Also note the optional field `unprocessed_participants`. This indicates which numbers could not be added to the group.\
To understand why this may happen and how to avoid it, see our guide: [why-arent-participants-being-added-to-the-group](https://support.whapi.cloud/help-desk/faq/why-arent-participants-being-added-to-the-group "mention")

***

### Simple example of AI bot in WhatsApp

{% embed url="<https://youtu.be/e4TNjiOfQ28>" %}

#### **JSON template**

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2Fx0NhyhdKJs2oiWY0sswB%2Fimage.png?alt=media&#x26;token=b133dca1-8e2b-4a03-9895-298d5eaca14d" alt="" width="281"><figcaption><p>Use import from file to start using the template</p></figcaption></figure>

### n8n WhatsApp Bot Template

We also provide a ready-to-use **n8n WhatsApp bot template** that demonstrates how to build a basic AI-powered bot using Whapi.Cloud.

The template is designed as a practical starting point for users who want to quickly deploy a working WhatsApp automation in n8n without building the flow from scratch. It includes a preconfigured workflow structure, message handling logic, and Whapi.Cloud API integration.

You can import the template directly into n8n and adapt it to your use case by extending the logic, adding buttons, enabling context retention, or connecting external systems.

{% hint style="success" %}
Check out our demo bot template on the official n8n website: <https://n8n.io/workflows/12722-create-an-ai-chatbot-for-whatsapp-with-whapicloud-and-openai-gpt-35/>&#x20;
{% endhint %}

The template is available on GitHub too:\
<https://github.com/Whapi-Cloud/whatsapp-n8n-bot>

This template is suitable both for quick demos and as a foundation for production-ready WhatsApp automations.

***

Need help getting started? We will tell you exactly how to create the scenario you need or help you find a mistake. Our support team is always here to assist you.
