The Webhook element in chatbots

Available with a paid pricing plan, as well as during the 7-day free trial

You can configure sending webhooks according to your chatbot flow script or activate global webhooks for different chatbot events and receive and save data in your system.

Let's take a look at what webhooks are, where they are used, how to activate them, and the structure of the received data.

Where webhooks are used

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 enable a webhook in a flow

You can add a webhook in the flow builder and track specific information as the user passes through certain elements in the flow.

Message User inputs their data or clicks on a button.
Action Opening a chat with an administrator, unsubscribing from a bot, updating a variable, assigning a tag.
Flow Starting a new flow.
Pause After the allotted pause time.
Filter Passing a set filter conditions.
API request Getting information on the request.

To insert a webhook sending, add an Action element after the element you want to track.

Select the Send Webhook option. Enter the name of the webhook to be sent and the URL to send the data to.

How to enable global webhooks

You can also enable webhooks that will be sent by events of the whole chatbot.

Go to bot settings, then the Webhooks tab. Activate the setting and insert the URL to which you want to send data.

Select the events you want to send alerts for and click Save to apply the settings.

You can select the following events.

Bot subscription Sent with information about when the user subscribed to the selected chatbot.
Incoming messages Sent with each new incoming message from the user in the chat with information about the user and the text of the message.
Outbound messages Sent with each message sent to the user with information about the user and the text of the message.
Opened live chat Sent after the user has passed the “Action” element with the “Open chat” option.
Launched custom trigger flow Sent when triggering flows with the user and flow information.
Redirect Sent when the user clicks on links in buttons and text with information about the link, sending element, and user.
Bot unsubscribe Sent when a user unsubscribes from a bot with information about the user and bot.
Bot blocked Sent when the user has blocked messages from the bot with information about the user and bot.

You can also enable chatbot payment tracking in your account settings. Read more: How to send a successful payment webhook.

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.

An example of a webhook sent from a chatbot flow

[
   {
        "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 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 Bot subscription:

[
   {
      "info":null,
      "service":"telegram",
      "title":"new_subscriber",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":1845120800,
         "id":"60b0a854b4d8073f592b92f3",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"name",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4964fd0f7b657847848"
      },
      "date":16377590567070
   }
]

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
   }
]

An example of a webhook for Outbound messages:

[
   {
      "info":{
         "message":{
            "channel_data":{
               "message":{
                  "disable_web_page_preview":null,
                  "text":"Click",
                  "disable_notification":null,
                  "reply_to_message_id":null,
                  "parse_mode":"HTML",
                  "reply_markup":{
                     "inline_keyboard":[
                        [
                           {
                              "payload_id":"84d30d5624-92245695-4e834560-86f4-bbdb694710b0456",
                              "callback_data":"eyJwIjoiODRkMzBkMjQtOTI5NS00ZTgwLTg2ZjQtYmJkYjY5NDcxMGIwIn05257",
                              "text":"Click",
                              "data":{
                                 "to_block_id":"3bd58f77-ef28-4f0d-9ae7-33ef71bedeb85724",
                                 "to_block":1,
                                 "button_id":"6cb63b34-a030-4e53-ba91-8f13320ad36b3687568"
                              },
                              "type":"postback",
                              "statistic_id":"6cb63b34-a030-4e53-ba91-8f13320ad36b5367637",
                              "external_id":"ce60c182-c058-4450-a002-2e500936ab536739",
                              "id":"6cb63b34-a030-4e53-ba91-8f13320ad36467346b"
                           }
                        ],
                        [
                           {
                              "payload_id":"97867499-063c-498d-9386-e26284addf1367568658",
                              "callback_data":"dummy",
                              "text":"Click",
                              "data":{
                                 "to_block_id":"9ba1c058-7ae8-429d-9d83-f674bf6635685b2f8",
                                 "to_block":null,
                                 "button_id":"bc769bd8-edef-42a6-9448-e47875b4663568999"
                              },
                              "type":"postback",
                              "statistic_id":"bc769bd8-edef-42a6-9448-e47875b46935683599",
                              "external_id":"5148a80f-0dc7-4bb9-aa26-8331a013568dfabc",
                              "id":"bc769bd8-edef-42a6-9448-e47875b46568586999"
                           }
                        ]
                     ]
                  }
               },
               "message_id":943544,
               "chat_id":6069664546956
            },
            "id":"619e3686cac8ab43e20a4a0546549"
         }
      },
      "service":"telegram",
      "title":"outgoing_message",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":"18451208006576",
         "id":"60b0a854b4d8073f592b925675f3",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"veronica",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4964fd0f7b65675675"
      },
      "date":16377585936738
   }
]

An example of a webhook for Opened live chat:

[
   {
      "info":null,
      "service":"telegram",
      "title":"open_chat",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":18451208007356,
         "id":"60b0a854b4d8073f592b92f673563",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"veronica",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4964fd0f756756b65"
      },
      "date":16377587917546
   }
]

An example of a webhook for Launched custom trigger flow:

[
   {
      "info":null,
      "service":"telegram",
      "title":"run_custom_flow",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":1845120856756700,
         "id":"60b0a854b4d8073f592b92f3564567",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"veronica",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4964fd0f7b655858"
      },
      "date":163775889778478
   }
]

An example of a webhook for Redirect:

[
   {
      "info":null,
      "service":"telegram",
      "title":"link_click",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":1845120806750,
         "id":"60b0a854b4d8073f592b9254677654f3",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"veronica",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4964fd0f65757b65"
      },
      "date":16377589785675
   }
]

An example of a webhook for Bot unsubscribe:

[
   {
      "info":null,
      "service":"telegram",
      "title":"unsubscribe",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":1845120806780,
         "id":"60b0a854b4d8073f592b92678f3",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"veronica",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4966784fd0f7b65"
      },
      "date":1637759687101
   }
]

An example of a webhook for "Bot blocked":

[
   {
      "info":null,
      "service":"telegram",
      "title":"bot_block",
      "bot":{
         "url":"https://t.me/best_bot",
         "external_id":1845126570800,
         "id":"60b0a854b4d8056773f592b92f3",
         "name":"BEST"
      },
      "contact":{
         "username":"veronica",
         "name":"veronica",
         "tags":[
            
         ],
         "last_message":"Test",
         "photo":null,
         "variables":{
            "name":"Veronica Petrova",
            "Phone":"380985236985",         
            "Email":"test@gmail.com"
         },
         "id":"60b0a854083b4964fd5670f7b65"
      },
      "date":1637756579166
   }
]

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

    Rate this article about "The Webhook element in chatbots"

    User Rating: 4 / 5 (14)

    Previous

    The Randomizer element in chatbots

    Next

    The API Request element in chatbots

    Popular in Our Blog

    Try creating a chatbot for Facebook Messenger for free