Table of Contents

How to Perform Basic Calculations

Do you need to perform basic mathematical calculations on your chatbot? Find out how to easily do this by setting variables!

Note: This Block is only available on Premium Accounts.

It is possible to perform mathematical calculations in your bot just using Set Variable blocks πŸš€

If you need more information on how to set a variable, you can read more about it in this article.

Set a Variable

In the Set Variable block, you must create or select the Variable you want to attribute a value to.

To perform calculations, you must use variables in the format of Number, so make sure you choose the right type πŸ˜…

Once you have created or chosen a Variable in the format of Number, you will see the option β€˜Perform a Calculation’.

Perform a Calculation

After selecting the Perform a Calculation option, you will notice that a new field is opened.Β 

In this field you can perform calculations to add, subtract, multiply, divide or make percentage operations.

First, you must define the value of the Variable you will be using in the calculation.

Keep in mind that this is an initial value, that will be altered as you build the calculation in your bot πŸ˜‰

Adding or Subtracting

To perform an addition or subtraction operation, create a new Variable or alter a preexisting one. This Variable will be the result of this calculation.

Insert a Start Value and End Value, which can also be variables.

Choose the β€˜ - ’ symbol between these two values to subtract, or the β€˜ + ’ symbol to add.

This is how the it will look like in your bot:

Multiplying or Dividing

To perform a multiplication or division operation, create a new Variable or alter a preexisting one. This Variable will be the result of this calculation.

Insert a Start Value and End Value, which can also be variables.

Choose the β€˜ * ’ symbol between these two values to multiply, or the β€˜ / ’ symbol to divide.

This is how the it will look like in your bot:

Final result

To show the final result on your bot, don’t forget to insert the Variable you have created/altered in a new block, like in a message or buttons block.

Percentage

Considering you already know how to perform add/subtract, multiply/divide operations, it will be easy to perform percentage operations! πŸ™Œ

Just like you learned in the previous mathematical calculations, to perform a percentage operation, you have to create a new Variable or alter a preexisting one. This Variable will be the percentage resulting of this calculation.

Insert a Start Value and End Value, which can also be variables.Β 

(a) Deducting a Percentage

Choose the β€˜ * ’ symbol between these two values, and multiply by 0.(percentage) .

For instance, if you want to find out how much is 30% off 100, you have to multiply 100 by 0.3 .Β 

Once you found out the percentage wanted, you just have to subtract it from the Start Value.Β 

(a) Adding a Percentage

Choose the β€˜ * ’ symbol between these two values, and multiply by 1.(percentage).

For instance, if you want to ad 30% to 100, you have to multiply 100 by 1.3 .

And that's it! Now you can do all the calculations you need in your chatbots πŸš€

Note: The ' % ' symbol in the Set Variable block does not perform percentage calculations. To read more about this, please check out this link.

Bonus 😎

1. You can format the ending result, for example if you want itΒ  to show only 2 decimals.

Check out how to do it in this link.

2. You can also perform calculations with Dates. 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.

How did we do?

Get started with the Formulas block

Contact