> For the complete documentation index, see [llms.txt](https://docs.chatlayer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/channels/webhook-api.md).

# Webhook channel

The Webhook channel provides a way to build a custom integration with Chatlayer that acts as a channel.

With the Webhook channel you can enrich the information sent via certain Channels. For example, instead of using the 'regular' Facebook Messenger or Whatsapp channel, you can use Webhook as a channel and send your messages via Webhook to Messenger or Whatsapp.

![With a regular channel integration, the channel is directly connected to Chatlayer](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MkHX1agNdUyA8LPHHKG%2F-MkI3-jY4I5godz5jNJ6%2Fimage.png?alt=media\&token=a4b02f9c-117c-4738-ac91-032ddbb86cfc)

![By using the Webhook channel, the channel of choice is indirectly connected with Chatlayer](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MkHX1agNdUyA8LPHHKG%2F-MkI3BJ1uPFYf84q7hWk%2Fimage.png?alt=media\&token=fc1a6326-ab76-4068-ac26-52cc41f162da)

The two images above show the difference between using the channel of your choice directly, or if you would like to use Webhook to enhance the channel possibilities.&#x20;

{% hint style="warning" %}
Don't confuse the Webhook channel, a custom integration channel, with [Webhook offloading](https://docs.chatlayer.ai/integrations/human-offloading-live-chat/offloading-webhook), designed for offloading to human agents.
{% endhint %}

## Sending User Messages & Receiving Bot messages

Our platform provides the following features:

* a Webhook message API endpoint to send a user message to the bot
* a Webhook configuration to be notified when bot messages are returned as response to a user messages sent to the webhook message API as described in [this section](/~/changes/zWOY8fNiBBrqneKkuGvA/channels/webhook-api.md#registering-a-webhook-api). This API is almost realtime and the purpose is to be able to trigger event-based behavior as soon as a bot message response occurs . This way you will be able to integrate the bot flow logic in your own application or message channel.

The overall mechanism is loosely based on Pubsub protocol and relies on HTTP request containing the bot message response being sent to a consumer Endpoint URL. The customer webhook Endpoint URL can be configured on our platform as described in [this section](/~/changes/zWOY8fNiBBrqneKkuGvA/channels/webhook-api.md#registering-a-webhook-api).

## Registering a webhook API

You can register a webhook API by adding a new channel type webhook in your channel configuration:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fchatlayer-documentation%2F-LjpUT_edCWf-bzj1EAX%2F-LjpZdxGUtQbBmODbZ1f%2F0.png?generation=1563193164478065\&alt=media)

Now configure both settings:

* **Webhook URL**: this URL must either be publicly available, or at least available from our platform's IP range. We strongly advise using HTTPS for this endpoint.
* **Verify token**: This can be any arbitrary string, but it is recommended to be chosen at random.

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fchatlayer-documentation%2F-LjpUT_edCWf-bzj1EAX%2F-LjpZdxHlfmPceW59YVD%2F1.png?generation=1563193164421033\&alt=media)

## Webhook messages

<mark style="color:green;">`POST`</mark> `customer webhook endpoint URL configured in Chatlayer.ai`

When a user message is sent to the webhook message API, the bot response(s) will be sent to the customer webhook endpoint URL. The bot response body payload object will include the bot message. This message can have a different object structure based on the message type.

{% tabs %}
{% tab title="200 " %}

```
  "recipient": {
    "id": "default-b94215f0-0c7e-11ea-9c43-7174cba76asdfoijadsfoiadsiojadfiojasodijfb12"
  },
  "verifyToken": "eenheeluniekeverifytoken",
  "message": {
    "text": "test tekst message"
  }
```

{% endtab %}
{% endtabs %}

## Message objects

A bot message sent to the customer webhook endpoint URL and returned as response to a user messages can have different object structures, depending on the message type. Want to learn how to build these message objects? Read about it here:

{% content-ref url="/pages/-LjqDAiDoJuB5Sfvuyub" %}
[Message types](/~/changes/zWOY8fNiBBrqneKkuGvA/integrations/chat-message-structure-for-apis.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/channels/webhook-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
