How to TEST your Http Request (Webhook block)
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:
- 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:
- 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:
- 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.
- 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.
- 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.
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:
- 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.
- 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: