Flow Operations > Set Variable

Note: This Block is only available on premium accounts.

Set a Variable is a powerful block that allows you to create, establish a format and set a value to a variable.

If you are unfamiliar with the concept of variable, think of it as box, that you can name and where you can store "things". In this case, "things" are values (numbers, texts, dates, etc...)

To create a "Set variable" block, all you need to do is selecting it from the block menu as in the above GIF.

Block anatomy & set up

Create or select a variable to modify:

You can select a variable that already exists or create a new one, just type the name (no spaces are allowed) and click on "create".

Select the format:

Here you need to specify the type of format the variable will store:

You have three options:

- Text (string)

- Number (float)

- Date (YYYY/MM/DD format)

"Type the value" section:

In this case, as the label says, you can type the value you want to give to the variable. It is also possible that instead of typing down such value, making it depends on other variable values.

Perform a calculation:

Number and Dates can be used to make calculation for the variables. For numbers, the available operations are:

- Addition (+)

- Subtraction (-)

- Multiplication (*)

- Division (/)

- Modulus "remainder" (%)

For dates, the available operations are:

- Addition (+)

- Subtraction (-)

For days, based on a variable that is a date (with Landbot format) you can sum or subtract days or month or years to that specific date:

Finally, once the block is set, you have two possible outputs: Success or Failed.

Why is there a "failed" option for a set variable block?

If everything is correct, we will continue the flow with the Success. However if the user had used wrong inputs or formats and we are using the "Perform a calculation?" feature, it will generate an error, and the flow will continue through the Failed output. It is a good practice to use it, to avoid the bot to crash.

Block user examples

Below three short example of how the Conditions block works:

EXAMPLE 1 - Concatenate variables: In case we would like to store in a variable (@userinfo) many inputs from the user (@name, @email and @phone) , to do so, we need to write the variables in a different way, here is how:

EXAMPLE 2 - Build url with variables: Maybe you need to build a url, where the customer will be redirected, with values from the inputs, here is how:

EXAMPLE 3 - Update variables value with new value: We can add values to the same the variable, progressively one question at a time. Here is how it would work:

Set Variable block Troubleshooting & Faqs

Can I do calculation between two dates?

Currently is not possible to do calculations between two dates.

How can I Set a Variable with the Date format?

In the Set A Variable block, the format for a Date variable should be YYYY-MM-DD


How did we do?