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 uses these webhooks in its stories to:
  • Send information (generated leads, signups, queries, and emails)
  • Receive information (status updates, alerts, weather information, and bus timings.)

Creating a New Webhook

To create a new webhook, click on New Webhook.
Add New Webhook
Just like any other API definition, a webhook has a request and a response.
  • The request should be configured on the BotDistrikt platform
  • The 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 add 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. Use these keys to remember the user's current session (product or topic they were talking about) or use the memory merge tags in responses.
For 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 personalized 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 display 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 display 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 empower your chatbot as it integrates with numerous external internet-connected systems (emails, business software, ERP and CRM platforms, and helpdesk software.)