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:

[
   {
        "info": null,
        "service": "messenger", // messenger - Facebook chatbot, telegram - Telegram chatbot
        "title": "Reserved. Apartment #3" // title of the webhook
        "bot": {
            "url": "https://m.me/104117781360763",
            "external_id": "104117781360763", // community identifier in the messenger (for Facebook, the value is passed as a “string”, for Telegram and VKontakte as a number).
            "id": "17ff4105-d5f1-4790-9d09-a6f64ea73d54", // identifier of the connected bot in SendPulse
            "name": "BEST" // 
        },
        "contact": {
           "name of variable": "value of variable",
            "email": "name@example.com",
            "phone": "+38093000000",
            "photo": "https://..",
            "tags": ["tag1", "tag2"],
            "id": "467bf50f-9cb0-4b65-b722-0135ad5fb9e0", // contact’s identifier in SendPulse
            "name": "Alexander"
        },
        "date": 1617401679 // execution date and time in milliseconds
    }
]
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 (11)

    Other useful articles

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger