Table of Contents

Formulas block (beta)

Pau Sanchez Updated by Pau Sanchez

Note: The Formulas block is only available on the Professional plan (and for a few extra months for Starter plan that helped us test this feature during the beta period.)

What are Formulas?

Formula block allows you to make complex operations with values inside Landbot, like you do in other platforms like Google Spreadsheets or Excel, and store the result in an outcome variable.

Whereas before you could only transform data with Javascript or with external API's, now you will be able to do it, easily, using Formulas.

How to create a Formula

1. Select the variable where you want to store the outcome of the formula

2. Choose the output that fit your needs

3. Set the formula

4. Save and use

Elements of the Formulas block

1. Output

In the Output field you can define or create the variable where the result of the formula is going to be stored

For the Block outputs you can choose the type of output that fit your needs. You have:

  • Success/Error: For mathematical operations

  • True/False: For types of formula in which the outcome is a boolean value

  • Custom: When you want specific results as custom outputs

2. Formula

Here is the editor, where you can create and edit formulas

Right under the formula you can check the result in real time plus test other values in the formula.

3. Formulas Browser/Docs

In this section, you will see all the available methods you can use in the Formulas block.

Things you can do when building your formulas

1. Formulas can use fixed values

2. Formulas can use Landbot variables

3. Formulas can use formulas inside formulas

4. Formulas can use same output variable

5. Formulas can be chained one after another

6. Formulas can be great with the Conditional block

Things to be aware of when building your formulas

1. Blue ticks!

To be a valid formula, make sure both ticks are blue

2. Output variable type

Make sure the type of the variable is the right format to the type of formula you are using.

For example, if you are creating a math operation, you want the variable of the output to be a number, not a string type.

3. True and False, are strings that start with Capital letter!

In case you are using a type of formula that the outcome can be a boolean value, remember that True or False will be strings that the first letter will be Uppercase.

4. System variables need " "

If you are planning to use Landbot System variables like @today, add the " " between those variables:

5. Not created variables need " "

If the variable is not created yet, it needs " " also to be a valid formula

6. Test before you go into production!

Test always to make sure the Formula works as expected

Types of Formulas


Comparison formulas available:

  • IsEqual
  • IsNotEqual
  • IsGreater
  • IsGreaterOrEqual
  • IsLess
  • IsLessOrEqual
  • IsSet

Examples of use case of Comparison formulas:

Check if input from the user is the same as a number

Check if age is above 18

Check if the variable email is set or not



Logical formulas available:

  • And
  • Not
  • Or

Examples of use case of Logical formulas:

Check if email contains "" AND the age is over 18


Check that the user did NOT select a color "red"

Check if the "city" selected is Barcelona OR Madrid

Or(IsEqual(@city, "Barcelona"),IsEqual(@city,"Madrid"))


Math formulas available:

  • Product
  • Quotient
  • Remainder
  • Subtract
  • Sum
  • ToFloat
  • ToInteger

Examples of use case of Math formulas:

Apply 20% discount

Product(@price, 0.80)
Get % of correct answers


Add +1 every time user passes through this step


Convert to only 2 decimals

Below is a formula where the variable @number has the value of 3.1415 and we only want 3.14

Quotient(ToInteger(Product(@number, 100)),100)

In case we want 1 decimal the Formula would be with 10:

Quotient(ToInteger(Product(@number, 10)),10)


String formulas available:

  • Contains
  • Length
  • Lower
  • Replace
  • Slice
  • Split
  • ToString

Examples of use case of String formulas:

Ensure the email is in lower case for proper validation


Get list out of options selected in Multiplechoice

Split(@options, ", ")

Note, if you want to limit the number of options, this will be handy if you add use also the Length formula and with a Conditional block, you redirect the flow according to the maximum number of options you require. Like in th example below:

Where the formula is:

Length(Split(@options, ", "))

Check if text is too long


In case we need to set a maximum, minimum or exact length for an answer, what we can do is to use the flow below, where we are going to check that the input of the user is no longer than 100 characters:

1. First we ask the user for an input, and store it in the variable @userinput

2. After that we will check the length of the @userinput, and store it's value in the variable @length_userinput (Number format)

3. Once you have that value, we will use a Conditional Block to check wether is that value greater or not than 100. Here is where we can set for any length that we want or condition that we want. Like only 10 characters.

4. After that we set up 2 flows, one, through the Green Output (True) in case it goes according to your needs, and another flow, for the Red Output (False) when we want the user to type again something that matches your criteria, by using another Question block, with a different text, but using the same @userinput variable


Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(@toreplace, "a", "i"),"e","i"),"o","i"),"u","i"),"y","i"),"é","i"),"è","i"),"á","i"),"à","i"),"ò","i"),"ó","i"),"ù","i"),"ó","i"),"ü","i")

Transform number's " . " (dots) into " , " (commas)

You will have to use 2 formulas for this one.

  1. One to turn the number from the Number format into the String format:

Make sure to save the result in the String format, and add the variable in the number format in the formula:


  1. Another Formulas block to Replace the " . " (dots) for " , " (commas):

Save it also in the String format, and add the following formula to replace the dots for commas:

Replace (@newstring, ".", ",")


Array formulas available:

  • Contains
  • GetValue
  • Length
  • List
  • Slice
  • Push

Examples of use case of Array formulas:

Get length of an arrays


Create an array out different strings


Add last user input to an array

Push(@arrayinputs, @lastinput)


Object formulas available:

  • GetValue
  • ToJSON

Examples of use case of Object formulas:

Get value from the key "Name"

GetValue(@response, "Name")

Get value from first item of the array that is in the key "colors"


Transform string to a JSON



Regex formulas available:

  • RegexTest

Examples of use case of Regex formulas:

Check if the input is of 10 digits number


Check if the input is a valid UK postal code


Check if the input contains a word that is "stop" or something that starts with "stop"


How did we do?

Keyword Options 🔑 Assign keywords to buttons (WhatsApp and Facebook)