Subscriptions

When massive messages are sent using HSM, notifications can be generated so that you can subscribe to that relevant information and your team can manage this data of each message using webhooks.

Webhook is a method for one system to notify another system or application about events or updates in real time. Firstly, you should verify if there are any subscriptions configured to be sure that it is already set in your bot or not in order not to duplicate subs. Afterward, you can subscribe to events you need.

Events Allowed

  • delivered_channel: The template was sent via WhatsApp.

  • delivered_user: The template was sent to the user.

  • failed: The template delivery failed.

  • read: The user read the template. This event will only be received if the user has blue double-checks enabled on WhatsApp.

  • reply: The user replied to the template

Get Subscriptions

GET https://api.jelou.ai/v1/bots/:botId/events/webhook

This endpoint allows you to get information from previous subscriptions

Path Parameters

Name
Type
Description
Required

botId

string

ID of the Bot.

Y

Headers Parameters

Name
Type
Description
Required

Authentication

string

Authentication token

Y

Example

curl --request GET \
  --url 'https://api.jelou.ai/v1/bots/BOT_ID/events/webhook' \
  --header 'Authorization: Basic {{Base64EncodedUsername:Password}}' \

Response

{
  "message": [
    "Webhooks retrieved succesfully!"
  ],
  "statusMessage": "success",
  "status": 1,
  "data": {
    "read": "https://webhook.site/22222",
    "reply": "https://webhook.site/22222",
    "failed": "https://webhook.site/0e09fd45",
    "delivered_user": "https://webhook.site/0e09fd45",
    "delivered_channel": "https://webhook.site/0e09fd45"
  }
}

Subscribe to Events

POST https://api.jelou.ai/v1/bots/:botId/events/webhook

This endpoint allows you to subscribe to your webhook

Path Parameters

Name
Type
Description
Required

botId

string

ID of the Bot.

Y

Body Parameters

Name
Type
Description
Required

webhooks

array

Array of webhook objects, each containing a URL and the events to subscribe to.

Y

url

string

Webhook URL

Y

events

array

List of event types that the webhook will subscribe to (delivered_channel, delivered_user, failed, read, reply)

Y

Headers Parameters

Name
Type
Description
Required

Authentication

string

Authentication token

Y

Example

curl --request POST \
  --url 'https://api.jelou.ai/v1/bots/BOT_ID/events/webhook' \
  --header 'Authorization: Basic {{Base64EncodedUsername:Password}}' \
  --header 'Content-Type: application/json' \
  --data '{
  "webhooks": [
    {
      "url": "https://webhook.site/0e09fd45",
      "events": [
        "delivered_user",
        "delivered_channel",
        "failed"
      ]
    },
    {
      "url": "https://webhook.site/22222",
      "events": [
        "reply",
        "read"
      ]
    }
  ]
}'

Response

{
  "message": [
    "Webhooks created succesfully!"
  ],
  "statusMessage": "success",
  "status": 1,
  "data": [
    {
      "url": "https://webhook.site/0e09fd45",
      "events": [
        "delivered_user",
        "delivered_channel",
        "failed"
      ]
    },
    {
      "url": "https://webhook.site/22222",
      "events": [
        "reply",
        "read"
      ]
    }
  ]
}

Last updated