×

40% OFF chatbot services

Get an annual plan by September 30

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: 

  • Bot subscription
  • Incoming messages
  • Opened live chat
  • Launched custom trigger flow
  • Redirect
  • Bot unsubscribe
  • Bot blocked

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, // information from messenger
        "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",
            "last_message": "hey! whats up?", // last message of the user
            "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
    }
]

An example of a webhook for "Incoming messages":

[
   {
      "info":{ // information from messenger
         "message":{
            "channel_data":{
               "message":{
                  "audio":null,
                  "from":1332678955,
                  "context":null,
                  "interactive":null,
                  "contacts":null,
                  "text":{
                     "body":"hey! whats up?"
                  },
                  "button":null,
                  "system":null,
                  "voice":null,
                  "video":null,
                  "identity":null,
                  "image":null,
                  "timestamp":1625834714,
                  "document":null,
                  "type":"text",
                  "id":"ABCDOAk1346346go-sKd--dduwQ9p",
                  "sticker":null,
                  "location":null
               },
               "message_id":"ABCDOAk1Z43535-sKd--dduwQ9p"
            },
            "id":"60e8434b446846838d8463"
         }
      },
      "service":"whatsapp",
      "title":"incoming_message",
      "bot":{
         "url":"https://wa.me/380932674329",
         "external_id":"380932674329",
         "id":"60c1c50c156845831909cf74",
         "name":"Revision_me"
      },
      "contact":{
         "username":"Alexander",
         "name":"Alexander",
         "tags":[
            
         ],
         "last_message":"hey! whats up?", // last message of the user
         "photo":null,
         "variables":{
            "dept":"Designer"
         },
         "id":"60c0f31f457479d02b7512"
      },
      "date":1625834714
   }
]
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 (13)

    Other useful articles

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger