How to Send Webhooks Via Chatbots

A webhook is a mechanism for transferring data to your system about user-generated events. It sends an HTTP request to your handler.

Using this integration you can collect and send data about events in a chatbot’s flow to your system for further work with this client.

Use case example, imagine: you created a form for new users to reserve a place at your conference using messenger. You want to know about each user that registered for a specific lecture so you can contact them or change their status in your CRM.

You can accomplish this goal easily by sending a webhook. As soon a user reaches the webhook element in your flow, the event data will send to your data storage system (i.e. CRM, CMS, site, etc) for future use.

How to add a webhook to your chatbot flow

Add an “Action” element after the element that you want to track. Choose the option “Send webhook”. Enter a title for the webhook and the URL where data will be sent.

You can track:

  • “Message” elements - user input, using a specific button;
  • “Action” elements - opening chat with admin, unsubscribing, updating variable, or adding a tag.

You can also specify events for which webhooks will be sent in the bot settings section. Enter a link to your handler and select the events themselves.

Send data about the actions of subscribers to your system with the following events: subscribing to a bot, opening a chat with an administrator, starting a flow, following links, unsubscribing from a bot, or blocking a bot by a client.

Webhook structure

A webhook сan transmit data about:

  • the date an action was completed;
  • title of the webhook - you can filter your audience based on if they received a webhook by its “title”;
  • information about the bot and the social page it is linked to- identification, photo, link to a page;
  • information about the contact who triggered event - their identifier, name, date of birth, city, country, profile photo, any existing variables, and tags.

Webhook data example:

{ "date": 1589542610, // execution date and time in milliseconds "contact": { "variables": { "name of variable": "value of variable", "email": "", "phone": "+38093000000",
"photo": "https://.."
}, "tags": ["tag1", "tag2"], "id": "0278981b-92f4-4bbb-8353-627b000d463", // identifier of the contact in your SendPulse audience list "name": "Alexander" }, "bot": { "url": "", "external_id": "6523336910330", "id": "064faef8f5251e35a68", // identifier of the connected bot in SendPulse "name": "Svitapp" // name of the page }, "service": "facebook", "title": "Reserved. Apartment #3" // title of the webhook }
Webhook data format changes
Note! The webhook data format was changed on August 11, 2020. Now it is an array of objects [{...}, {...}]. Previously, there was one data object {...}. Update your integrations if they use the old format.

Webhook data is sent with a content type “application/json”.

Rate this article about "How to Send Webhooks Via Chatbots"

User Rating: 4 / 5 (10)

    Other useful articles

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger