Webhook Block (Builder v.3)

Sometimes we need to send data collected in the bot to external apps or servers, sometimes we want to bring data from outside sources to the bot, from API's, CRM's... either way we can achieve this by using HTTP Methods like POST and GET.

The block to do that is the Webhook block. As the name says, it can be use to connect with external webhooks (like Zapier)

But you can use the same block to contact an external server and make the most of RESTful operations with the following HTTP Methods: POST, GET, PUT, PATCH and DELETE

Landbot Webhook blocks do not accept XML, only JSON

Sometimes we need to integrate our bot with an external API, maybe for

URL & Method

In this section we will write the url (endpoint) to contact the external service and the method used (GET, POST...)

Sometimes the url will have to be modified based on variables from the user, below are examples on how to implement the variables as a parameters, instead to send them through the body (Send data from variables input):

https://api.test.com/something/@name

https://api.test.com/something?name=@name

It's important that the service that your are working with uses proper SSL Certifications, otherwise the Webhook won't work and no error is displayed. If you have your doubts you can check it in this site

Send params?

Information can be sent in the shape of the body or as params

Customize headers?

By default, headers are disabled, if you want to use them, just switch it.

In this section we will set up (if needed) the header of the request. Like the body it needs to be properly formatted, otherwise we will have an error.

When we need to specify the "Content-Type", the most common one is JSON, so it will be like this one : {"Content-Type": "application/json"}

Note, that the Content-Type depend on the external service you are doing your request. Sometimes, the most common error is that the Content-Type is a different one: { "Content-Type" : "application/x-www-form-urlencoded" } Bear in mind that for this type, all the variables in the body of the requests, must have a value.

Header is also the place where, if needed, you should add the Authorization token like:

Customize body?

Sometimes we need to send information in the body of the request instead of the URL, so here is the space to do it.

It is very important to use JSON standard otherwise we will have an alert error saying: JSON Parse error! and the border of the input area will be red,

Here is an example of a body formatted correctly in JSON:

{"email": "@email", "name": "@name", "custom-variable":"@customvariable"}

Test

Here is where we can check if all the previous setup is done correctly. Note, that this step is necessary if you want to store values from the response

Once clicked the TEST button, it will trigger a request, with the previous set up and below will display the actual Response from the API and the Status Code.

Above we can see a Tests are "real", and will send real requests to your desired API.

Save response?

In the older version, we used the Callback block to do it

When we need to store the response, this is the section.

To make it work properly, so that Landbot identifies the property key names of the response, you have to do a test first. Then you can assign as many Landbot variables to as many values from the response you want. As long as in the test such key property names had been identified.

Response routing

In the older version, we used the Callback block to do it

This part of the webhook block is used to set up routes depending on the Status of the response.

And set up flows after the webhook accordingly


How did we do?