Setting Webhook
A webhook is a way for an application to send real-time data to other applications as soon as an event occurs. Instead of waiting for you to request information, a webhook delivers the data to a specified URL immediately when the event happens. That is, Webhook defines a notification event to be sent and handled by your application, passing on the data that identifies the step in the flow to which webhook corresponds to the user has arrived, another out-of-flow action.
When configuring the chatbot in the Interactions section, you have the option to enable the webhook from the Welcome Message or each Interaction.
There are two options to enable the webhook, by choosing the Attribute option from the Redirect Type, or enabling the webhook through a toggle switch after setting both Redirect Type and Redirect To.
Activating Webhook via Toggle switch
In this configuration, the webhook is invoked as soon as the end user interacts with the chatbot option. This means that the webhook is triggered immediately when the end user selects an option from the chatbot menu.
For example, when the end user interacts with the chatbot, they receive a message asking them to choose an option for streaming membership: Welcome to EliPackage, enter the best option for streaming membership: 1. One month, 2. Six months, 3. One year
The webhook is invoked as soon as the user responds with their choice.
Therefore, this event will be recorded in the (URL) that was shared by the user, in the option
parameter (option chosen by the end user) and keyword
parameter (keyword entered by the end user) from the Payload , as shown below:
{
"campaignId": "13010",
"label": "Welcome Message",
"option": "One month",
"keyword": 1,
"phoneNumber": "+525500000000",
"date": "2024-06-18T23:26:14.206Z"
}
After understanding both options for enabling the webhook, the next step is to specify the URL to which the webhook will send data and the method it will use. This URL must be capable of handling incoming HTTP requests.
Webhook Configuration
By enabling the webhook by choosing the Webhook _option from the _Redirect Type, or enabling the webhook through a toggle switch, your endpoint must have a POST access method and receive a JSON body.
You must type the following URL structure on the URL placeholder:
POST https://<Your_Domain>/<Your_Path>
The Webhook is divided by two components: Payload and Headers.
-
Payload: The URL typed is the external callback where the events of the message will be registered and published. That is, the following example parameters sent to your callback URL will be the events to be recorded in the callback once the end users begin to participate in your campaign.
When you enable the webhook via Redirect Type, the example parameters to be sent to your callback URL are the following:
{ "campaignId": "13010", "label": "Welcome Message", "phoneNumber": "+525500000000", "date": "2024-06-18T23:22:36.560Z", "response": "John Doe" }
Parameter Description "campaignId"
Unique identifier of the campaign. "label"
Section of the chatbot. In this example, we are located in the Welcome Message section. "phoneNumber"
Phone number of the end user. "date"
Date when the Webhook receives the message.
The date is represented with date in UTC Zulu format: (yyyy-mm-dd-Thh:mm:ss.ssZ)."response"
Response entered from the end user who participated in the campaign. When you enable the webhook via toggle switch, the example parameters to be sent to your callback URL are the following:
{ "campaignId": "13010", "label": "Welcome Message", "option": "One month", "keyword": 1, "phoneNumber": "+525500000000", "date": "2024-06-18T23:26:14.206Z" }
Parameter Description "campaignId"
Unique identifier of the campaign. "label"
Section of the chatbot. In this example, we are located in the Welcome Message section. "phoneNumber"
Phone number of the end user. "option"
The option chosen by the end user who participated in the campaign. "keyword"
Keyword entered by the end user who participated in the campaign. "date"
Date when the Webhook receives the message.
The date is represented with date in UTC Zulu format: (yyyy-mm-dd-Thh:mm:ss.ssZ).If you want to add additional parameters, from the Body textbox type in JSON format each parameter.
-
Headers: You can specify custom headers that the platform will use while sending the payload to the specified webhook endpoint. Custom headers give the destination application an option to authenticate your webhook requests, and reject any that do not contain these custom headers.
The headers use key-value parameters that are sent as part of the webhook request. The values of these key-value pairs are visible and editable in the webhook editor by selecting the Edit icon once the key-value have been added. And, you are able to delete the key-value by selecting the Delete icon.
As Header example, the following headers key-value will be sent with all requests:
As an example representation when configuring the chatbot, note the Actions icons at the far right of the table for editing or deleting a menu entry. And to the right of the icons a link icon that denotes the presence of a webhook associated with the option, where the first webhook is explicitly as a webhook Redirect to, while the other two are webhooks associated with the selection of an interaction and a campaign, an underlying webhook.
Graphically, from top to bottom they are as shown below.
To summarize the graphic, there are two outcomes that remain within the platform, options 1 and 4 of the menu (blue arrows), with option 1 being a plain interaction and option 4 and interaction (blue arrow) with a webhook underlying it (black arrow).
There are two outcomes that have platform campaigns as their next action, options 2 and 5, with option 2 invoking a Raffle Giveaway campaign (red arrow), and option 5 invoking a Web Polls & Surveys campaign (read arrow) with an underlying webhook (black arrow).
Updated 14 days ago