Your bot doesn’t have to be just a chatty assistant. It can also handle more advanced actions for you such as completing purchases, sending receipts and sending updated data from your databases. You can do that using webhooks.
Webhooks, also called a web callback or HTTP push API, are the API concepts that are getting more and more popular. Thanks to their lightweight and speed they provide data between applications immediately. With webhooks, you can pass and retrieve information from a matched interaction to your web service.
Main characteristics
-
you can set up separate webhooks for each interaction
-
pick the language you like to create webhooks:
PHP
,Node.js
,Java
,JavaScript
,C++
etc. -
webhooks returns data to your bot, that’s why responses from webhooks are added to bot responses
How to set up my first webhook
Go to our Setting up your webhook tutorial to check how you can create your first webhook connected with ChatBot.
Webhook request
When an interaction has a filled Webhook section, our backend service send the matched interaction to the webhook by POST
request.
Webhook schema
Example of the request content sent to the webhook address:
{
" chatId": "5cc6d3c0b4001336f89de71a",
"messageId": "5cc6d3c0b4001336f89de71a",
"userId": "5cc6d3c0b4001336f89de71a",
"externalId": "String", // external userId
"userAttributes": {
"default_name": "John Doe"
},
"attributes": {
"age": "31"
}
}
Limits
-
Timeout for service response is 10 seconds;
-
The maximum response size 100kb;
-
The response must be provided in JSON format;