Builder blocks
Webhook block
27 min
sometimes we need to send data collected in a bot to external apps or servers, or bring data from outside sources (e g api, crm etc) to the bot — we can achieve this with the webhook block webhook lets your bot perform restful operations with external webhooks, apis, or servers using the following http methods post get put patch delete head connect options trace landbot webhook blocks do not accept xml, only json url & method in this section, you can set the http method used (get, post, put ) 2\ url (endpoint) of the external api warning the url must be an https //la/ otherwise you will get an error that will not allow you to save changes if you want to make parts of the url dynamic based on user attributes or inputs, you can insert variables from the picker variables will only work in the url path, not base url ⟶ domain com/@{variable} ✅ , @{variable} domain com ❌ custom variables will be formatted as @{variable} and system variables as ¿·@variable·? see below for an example if you want to attach parameters to the end of the url, it's best to set them up in send params section 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 https //www sslshopper com/ send params if you want to attach parameters (e g ?user=elon) to the end of a request url, you can set them up in this section as key value pairs added parameters will appear in preview url in green (note they won't appear in the url field where you type) customize headers headers in http requests are commonly used for authorization, specifying content type etc by default, headers are disabled if you want to send headers, just switch this section on you can set headers as key value pairs once set up, they will be sent in json format in an actual request for example, if key = accept, value = text/html ⟶ {"accept" "text/html"} the specific headers you need will depend on the api you are connecting here are some common examples specify content type as json format ⟶ content type application/json content type depends 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 authenticate api key ⟶ authorization bearer 1234567abc specify user agent ⟶ user agent mozilla/5 0 (iphone; cpu iphone os 13 5 1 like mac os x) applewebkit/605 1 15 (khtml, like gecko) version/13 1 1 mobile/15e148 safari/604 1 landbot doesn't send user agent as a header by default please add it if needed customize the body if you need to send information in the request body instead of the url, you can add it to this section warning request body must be written in json format, or you'll see validation errors here is an example of a body formatted correctly in json { "email" "@email", "name" "@name", "custom variable" "@customvariable" } variables must be wrapped in quotes ⟶ "@variable" test your request you can test whether a request can work properly in this section click on test the request it will trigger a real request to your desired api response status code & body will appear below the test button manually set values for test variables (optional) if your request contains variables, you may want to manually set their values for testing purposes you can do so in this section before making a test request save response you might want to save the response of a request as variables every time it's triggered to split bot flow ⟶ e g check a user's record in crm to check if he is an existing customer display data as options in the next step using https //help landbot io/article/qv32dpil6w integrations dynamic data arrays block ⟶ e g get up to date inventory data from the external database and display them as products for purchase store a record ⟶ e g get a user's data from a 3rd party api, and save it in your own database this is the section to do so by default, the entire response body will be saved if you want to save a specific part of the response, you need to test your request in the previous step first to identify json keys select the value you want to save from the dropdown 3\ save it as a variable you can break down the response into however many variables as you want webhook outputs the webhook block has a green and red output, the green output is for successful calls and the red output means that the call failed due to a timeout, or an unreachable server something to keep in mind is that responses such as 'forbidden', or 'not found' will go through the green output, for those cases you'll need to use response routing response routing if you want to split the flow based on the response status code , you can do so in this section once you've specified all the paths, go to your canvas to set up their subsequent flows we currently don't support range routing (feature coming soon) you can only trigger a path by having the exact same status code instead of an entire range, such as 4xx responses with no specified path will follow the default flow every time you change options in the block editor, you will have to re connect them on canvas need a more practical description of how to use this feature? check our guide on https //help landbot io/article/yapkl17tdg how to post get and more with landbot v 3 with your bots domain variables domain variables allows developers to switch predefined base urls, in a simple manner instead of typing a specific url for each webhook block in a static manner, domain variables, can be selected from the domain variables button below the url once a domain variable is set, you can continue the edit adding the rest of the path, even add more landbot variables or if needed, you can always delete the current the current domain variable and path at once domain variables (headers) domain variable can also being set up with specific headers, that will be loaded also to those webhook using such domain variable how to set domain variables from the webhook dashboard section ( https //app landbot io/gui/integrations/webhook?section=domain variables ) you can add, edit and delete domain variables to create a new domain variable, press create fill the data (name, url, and headers) change environment (edit a domain variables) if at some point you need to change the values of a domain variable because you are changing from development to production for example, instead of changing every webhook, you just need to edit the domain variable that is being used and the changes will be applied automatically, without the need to change anything in your current bots where you are using such domain variable error log in this section, you will be able to check information about errors and it's details landbot public ip in case you need to whitelist landbot’s ips, they are 34 77 31 159 23 251 142 192 channel type compatibility for web this feature is fully compatible for whatsapp this feature is fully compatible with whatsapp for messenger this feature is fully compatible with messenger