How to TEST your Http Request (Webhook block)

Pau Sanchez Updated by Pau Sanchez

The Webhook block allows you to trigger an Http Request to external APIs once the visitor "passes through" the block. It is very handy when you are looking to connect with external databases or CRMs, however, as powerful as it is, it needs to be correctly set up and tested before you can use it.

Here we will show how to test the set up of your webhook step by step:

  1. Set up all the parameters needed according to the documentation of the service you want to connect.

In this example we are going to use the OpenWeather API, and get the weather based on the city:

  1. Now instead of using a static value like "London", we want to use a variable that we are going to ask to the user, in this case it will be @city.

So the set up of the Webhook will look like this:

  1. Now the Webhook is set up but we need to test it out to make sure everything is correct, and then be able to Save the Response. But if we press TEST it will return an error because the variable @city has no value in that test.

  1. To be able to give a value to the variable @city, to test the Webhook block and without the need to change the previous configuration, we will activate the section called SET TEST VARIABLE'S VALUES.

  1. Once this section is activated, we will see a space where we will add a value for the variable city, that will be used only during the TEST.
Landbot variables can be in the URL, in the params, in the Header and in the Body

Here you will notice that we represented the variable @city with just the name "city". And the value that we will use will be "London". The format of the section needs to be a valid JSON.

This example would work if we where testing a webhook with the variables @name and @email:

{
"name":"Test Name",
"email":"test@email"
}

  1. Now that everything is set, the configuration of our request and the test variables' values, we can press TEST, and the result will be displayed below.

  1. Now we can configure the Save Response section according to our needs by selecting the key of the response.

And assigning in which Landbot variable we want to store the value:

In case you want to store the whole response, do not select any key from the dropdown, just add the name of the variable.

How did we do?

How to encode a variable

Builder's keyboard shortcuts and mechanics! 🏗

Contact