Table of Contents

Resume flow based on external process with Landbot API (Request, Set, Go)

Pau Sanchez Updated by Pau Sanchez

There are flows, that need an external process to be done to resume before the user can proceed. And at the same time, that process might be conditioned. For example a payment processed that is being done outside Landbot.

Here we will explain the basic concepts you can use to make this flow possible:

1st - Request

First of all we have a flow where we request the data that we will need, in this example name and email:

After, before we trigger the request, we need to set up a Set Variable block, with the variable that we will set with the value from the external service. The best approach is to use an empty object:

Here we use the variable @data type ARRAY, which will be an empty object

Right after we add the Webhook block that will trigger all the process.

It is paramount, to pass in this request 3 properties, that we will need later in to the Set and Go steps:

1. Bot id

You can find the bot id in the url of the builder, in the example below we can see that is the 1010178

2. Node id (you can do it later)

We need to indicate to the bot, where to resume from the flow. To do that we will select the Formula block that we will use later. Press right click on that block an press copy

In this case the id of this Formula block is "Nkqgn6xkf"

3. Customer Id

Last the customer_id is the value of the variable @id

So we can use this data in the body of our webhook, among the rest of the required data:

Obviously you can adapt the payload to your API requirements.

After the Webhook block, we are going to display a message to the user, that they should wait until the process is resolved:

As you can see, the last block is not connected. The "jump to" the other block, to continue, will be done from your custom externa service using Landbot API

2nd - Set

To set the values, from the external service we will use the API method called "customerFields -Change", as we are not creating such variable, it will be the PUT method.

We created previously the @data variable to hold the data, therefore the request will be as follows:


curl --location --request PUT '' 
\--header 'Content-Type: application/json'
\--header 'Authorization: Token {{YOUR API TOKEN}}'
--data-raw '{ "type": "object", "extra": {}, "value": {"status":{{status}}}}'

3rd - Go

To "go", to resume the flow, we need another API method, this time will be the Customers - Assign bot method:

As you can see here, we will need the customer_id, the bot_id and the node_id. Below we will is code you can use. Note also that "launch" value should be true.

curl --location --request PUT '' 
\--header 'Content-Type: application/json'
\--header 'Authorization: Token {{YOUR API TOKEN}}'
\--data-raw '{ "launch": false, "node": "{{bot_id}}"}'

Now, that we have the variable @data, and the bot is "going" we can extract the data from the variable @data, to do so, the best approach will be using the Formula block, right where the flow continues:

And finally, once we have the flow going, and we extracted the value of "status" and store it in a Landbot variable called @status, we can use for example a Conditional block to decide which message are we going to show to the user:

How did we do?

Generate a URL that has variables from user answers

Creating Masks for User Input (2 examples)