Links

Webhooks

Webhooks allow your bot to send and receive data to external internet APIs.
Webhooks allow you to connect your chatbot to your web services. Pass information from interactions and retrieve the result. Your bot is able to send and receive information from your external internet-connected systems with REST APIs.
Webhooks

Webhooks Page

Webhooks Dashboard
Your bot will be able to use these webhooks in its stories to send information such as generated leads, signups, queries, and emails, and receive information such as status updates, alerts, weather information, and bus timings.

Creating a New Webhook

To create a new webhook, click on New Webhook
To create a new webhook
Just like any other API definition, a webhook has a request and a request. The webhook's request should be configured on the BotDistrikt platform, while the webhook's response should be configured on your API server.

Webhook Request

The webhook's request is configured on the BotDistrikt platform. These are the following fields you have to configure for every webhook.
Field
Description
Name
A unique name to describe what the webhook does
Method
GET or POST
URL
The URL of your API to be called
Query Params
The data parameters to send to your URL. In a GET request, these are sent as query parameters directly on the URL, while a POST request, these are sent as body parameters in JSON.
Here is an example of a webhook configuration that gets a random number
random number webhook
The example above shows a simple webhook that calls the URL https://botdistrikt-webhook-examples.glitch.me/random_number with the query params min=10&max=20.

Webhook Response

The webhook's response has to be generated by your API server. Every webhook response should be in JSON format, and should contain at least one of the following keys:
{
responses: [],
memory: {},
user_attributes: {},
quickreplies: [],
}

responses

responses can be an array of strings. These strings will be added on to your bot's response to your user. Take a look at how it is done in this example
Story
API
Webhook Response
Execution
Let's create a story with a webhook that returns responses
{
success: true,
responses: [
"Here's your random number: 20",
]
}
Let's see how the response is displayed to the user
memory
memory should be an object of key-value pairs that are assigned to the user session's memory. These keys can then either be used to remember the user's current session, such as which product or topic they were talking about, and can also be used with the memory merge tags in responses. Take a look at this example
Story
API
Webhook Response
Execution
Let's create a story with a webhook that returns memory. Notice the merge tag {{memory.favourite-thing}}.
{
success: true,
memory: {
"favourite-thing": "cars"
}
}
Let's see how the response is displayed to the user. Notice the merge tag {{memory.favourite-thing}} is replaced with cars.
user_attributes
user_attributes should be an object of key-value pairs that are assigned to the user's profile. These keys can then be used to segment users in the Users dashboard, and to create targeted groups for personalised stories and broadcasts. Take a look at this example:
Story
API
Webhook Response
Execution
Let's create a story with a webhook that returns memory. Notice the merge tag {{user.age}}.
{
success: true,
user_attributes: {
age: "28"
}
}
Let's see how the response is displayed to the user. Notice the merge tag {{user.age}} is replaced with 28.

quickreplies

quickreplies can be an array of strings. These quick replies will be shown as options to your user. Take a look at how it is done in this example
Story
API
Webhook Response
Execution
Let's create a story with a webhook that returns quickreplies. These will then be shown as quick replies to the user
{
success: true,
quickreplies: [
"Chicken",
"Fish",
"Vegetarian",
"Vegan"
]
}
Let's see how the response is displayed to the user.
Webhooks make your chatbot very powerful as it can be integrated with any number of external internet-connected systems like emails, business software, ERP and CRM platforms, and helpdesk software.
Last modified 1mo ago