OLD BUILDER - Set a Variable

This article corresponds to the V2 (Classic) of the app. You can check the equivalent for the new version V3 (Bricks) here

The 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 give it a name, and where you can store "things" in this case, things are values (number, texts, dates...)

Note: Set a Variable is only available on premium accounts

To create a Set a Variable block, click on Power-ups and the Set a Variable inside the chatbot builder

Then you have the following options:

Create or select a variable to modify:

You can select a variable that already exists to work with

In case you want to 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)

After that you have the section "Type the value or select a variable":

In this case, as the label says, you can type the value that you are going to give it to the variable. It is also possible that instead of typing down such value, it depend on other's variable value, so you can use it in here.

Perform a calculation:

Number and Dates, allow to do calculation for the variables, below will show some examples of useful cases to use those calculations:

For numbers, the operations that are available are:

- Addition (+)

- Subtraction (-)

- Multiplication (*)

- Division (/)

- Modulus "remainder" (%)

For dates, the operations that are available are:

- Addition (+)

- Subtraction (-)

For day, 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 will 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.

How did we do?

Powered by HelpDocs

Powered by HelpDocs