# Calculator

**Calculator** is a field in the "**Editor"** block that opens when you click on the tab with the same name. In this field, you can perform logical or arithmetic operations, execute functions of API requests from the builder, and available integrations.

It allows you to assign (declare) a variable for the client who has entered this block or update the values of existing variables. This functionality is especially useful for building funnels or tracking traffic sources.&#x20;

{% hint style="success" %}
The article with the same title explains how [to work with variables.](/chatbot/functions/calculator/variables.md)
{% endhint %}

<div data-with-frame="true"><figure><img src="/files/erfqdG8RBmA37Uc5oguw" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="danger" %}
Key points:

When working with the calculator, a variable name cannot start with a number.&#x20;

<mark style="color:red;">**Incorrect:**</mark> <1\_name>\ <mark style="color:green;">**Correct:**</mark> \<name\_1>.

A variable name cannot contain spaces; use an underscore "\_" to separate words.\ <mark style="color:red;">**Incorrect:**</mark> \<Client Name>\ <mark style="color:green;">**Correct:**</mark> \<Client\_Name>

For more details, read the article <mark style="color:red;">"Variables."</mark> <mark style="color:red;"></mark><mark style="color:red;">**ссылка**</mark>
{% endhint %}

## **How to use the Calculator in the Builder**

{% hint style="danger" %}
There is no need to use the **#{}** syntax when referencing a variable.
{% endhint %}

Example of calculating a variable’s value in the **Calculator** field:

<div data-with-frame="true"><figure><img src="/files/4ym6sfhR4gaiyhKMA05W" alt="" width="563"><figcaption></figcaption></figure></div>

Variables can be referenced either by their name directly or using the **#{}** syntax. All variables are automatically converted to floating-point numbers.

The calculator supports all necessary logical and arithmetic operations.

### Comments in the Calculator

To add comments in the **Calculator**, use **/\* comment text&#x20;*****/.*** This */* \*/ syntax allows you to write both single-line and multi-line comments:

<div data-with-frame="true"><figure><img src="/files/3xfpEOgH3zHT9MS3L24i" alt="" width="563"><figcaption></figcaption></figure></div>

Remember to always close your comment with the **\*/** tag at the end; <mark style="color:red;">**otherwise, the comment will continue onto the next line.**</mark>

<div data-with-frame="true"><figure><img src="/files/iWvtPRvr7h4cXimrhbcD" alt=""><figcaption></figcaption></figure></div>

Remember to include the closing tag for the comment, even if the comment is the last line in the "Calculator" field.

{% hint style="warning" %}
Don’t place comments directly one after another; there must be at least one empty line between them.
{% endhint %}

### **Constants**

"**E**": Euler’s number e&#x20;

### **Supported operators**

"**+**": addition&#x20;

"**-**"': substraction&#x20;

"**\***" *multiplication*&#x20;

"**/**": *division*

"**%**'"*: remainder of division*&#x20;

"**^**" "**\*\***": exponentiation&#x20;

"**==**" "**!=**" "**>**" "**<**" "**>=**" "**<=**": comparison operators&#x20;

"**and**" "**AND**" "**&&**": logical AND&#x20;

"**or**" "**OR**" "**||**": logical OR

{% hint style="warning" %} <mark style="color:red;">**Important!**</mark> Logical triggers with variables must be written in the <mark style="color:red;">**"Variable"**</mark> field, not in the "Trigger" field!
{% endhint %}

For example, the transition along the connector will occur if the variable **Phone\_Number** is filled. See the figure below:

<div data-with-frame="true"><figure><img src="/files/iCMe8wvHTzskYM7YZVLW" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="warning" %}
Note!&#x20;

If you compare a variable to a value in quotation marks, make sure there are no spaces between the quotes and the value; otherwise, the block may fail to trigger or behave incorrectly!

<mark style="color:green;">**Correct**</mark> (no space <mark style="color:red;">**before the quotation mark**</mark> or <mark style="color:red;">**after the value my\_new\_bot**</mark>):

<img src="/files/HBv6shc4xb7UCcQRyL6S" alt="" data-size="original">

<mark style="color:red;">**Incorrect**</mark> (with a space before the quotation mark):

<img src="/files/9h4jIrt83sfAszcYuOpd" alt="" data-size="original">

{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/chatbot/functions/calculator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
