# Whatsapp Cloud API

#### WhatsApp Cloud API

{% stepper %}
{% step %}

## Get your credentials

In the [Meta for Developers](https://developers.facebook.com/) console, open your app and copy:

* **Phone Number ID** — in **WhatsApp → API Setup**, listed next to each phone number you've added.
* **WhatsApp Business Account ID (WABA ID)** — also under **API Setup**.
* **System User Access Token** — under **Business Settings → Users → System Users**. Generate a token with the `whatsapp_business_messaging` and `whatsapp_business_management` permissions. For production, use a System User with a non-expiring token rather than the temporary token shown on the API Setup page.

You'll also choose your own **Verify Token** — any random opaque string. Meta will echo it back during the webhook handshake and GLChat Messaging will compare it to what you registered.
{% endstep %}

{% step %}

## Register the credentials in the Admin Dashboard

Add a new WhatsApp provider configuration, choose **WhatsApp Cloud** as the provider, and supply the Phone Number ID, WABA ID, System User Access Token, and the Verify Token you chose. Save the configuration.
{% endstep %}

{% step %}

## Configure the webhook in Meta

In the Meta developer console for your app:

1. Open **WhatsApp → Configuration**.
2. Under **Webhook**, click **Edit**.
3. Set the **Callback URL** to:

   ```
   https://<your-glchat-messaging-host>/whatsapp-cloud/webhook
   ```
4. Set the **Verify Token** to the same string you registered in step 2.
5. Click **Verify and save**. Meta will issue a `GET` to your callback URL with the verify token; GLChat Messaging will respond with the challenge if the tokens match. If verification fails, the most common causes are a token mismatch or the callback URL not being publicly reachable over HTTPS.
6. Once verified, under **Webhook fields**, subscribe to at least:
   * `messages` (required — incoming user messages)
   * `message_template_status_update` (optional — only if you use template messages)
     {% endstep %}

{% step %}

## Assign the bot number

In the GLChat Admin Dashboard, assign the WhatsApp phone number to the configuration. See [Admin Dashboard: Add Bot Number](/glchat/organization-admin/how-to-guides/integration-and-services/messaging-channel.md).
{% endstep %}

{% step %}

## Test

From your phone, send a WhatsApp message to the number. The webhook should hit your GLChat Messaging logs, and a reply should arrive back in your chat. If the webhook never fires, re-check the subscription on the `messages` field — Meta does not deliver messages until you've explicitly subscribed.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gdplabs.gitbook.io/glchat/developer-documentation/glchat-messaging/configuration-setup/whatsapp-cloud-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
