# Variables

{% hint style="info" %}
Variables allow you to save messages and personal user parameters (for example, name, id, points scored, etc.), set conditions (current date and time, type of channel in which the message was received), perform mathematical operations and embed dynamic text in messages .
{% endhint %}

![Так выглядит раздел переменных в Smartbot Pro](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FNZ4CZIgFnizJqG7YHPFK%2F1.png?alt=media\&token=080012ba-e40b-40ed-94c5-1e37f9ceba5a)

{% hint style="info" %}
Variables are keys in the format %variable\_name% that will be replaced by the bot with variable values ​​in the message text or condition.&#x20;
{% endhint %}

For example, if you write %name% in the text of the message, the bot will replace this variable with the username. There are two main types of variables: special and user defined.

### Special Variables&#x20;

They are already pre-installed by the developer in the bot, they cannot be deleted or changed. Special variables perform complex functions, such as returning the user's id, storing the last message received, keeping track of local time, and so on.

![Here is a far from complete list of special variables in Smartbot Pro that you can use](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FAReXuzMij35eAs3rT0D1%2F2.png?alt=media\&token=4ee5d44c-291c-4743-89ab-51577a2a0f52)

### User variables

You can create and modify them yourself. Just click the "+Add variable" button.

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FOo5LkXKJY5kVYJJe6vwr%2F3.png?alt=media\&token=15962b04-09b7-4e77-86fb-122a777ca3c6)

Let's say it can be a bonus counter %Points% or a variable %already participated%, the initial value of which is "no", but after a certain action it will change to "yes" and will not allow the user to go through the activity again.&#x20;

Custom variables can be local (that is, the value is individual for each person) and global (the value is common to all users). Types of variables

### Types of variables

> **Attachment** - you can save a file into this variable: a picture, a document, an audio recording, etc.&#x20;

> **Line** - a word, a phrase, an individual code. For example: %status% = "client"

<figure><img src="https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2Fn3tLirxk02Zjh2RIbPYT%2F%D0%9A%D0%BB%D0%B8%D0%B5%D0%BD%D1%82.png?alt=media&#x26;token=d0708bf3-7027-4702-af1a-d506dc44a282" alt=""><figcaption></figcaption></figure>

> **A number** is a number that can be used for calculations. For example, a replenishable bonus counter; personal balance in the game; virtual currency.

<figure><img src="https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FUeLwzKmP9NMRDrgJAZzj%2F%D0%91%D0%B0%D0%BB%D0%B0%D0%BD%D1%81.png?alt=media&#x26;token=b305bf1f-3c87-41ec-be8f-c65f94db6298" alt=""><figcaption></figcaption></figure>

> **A flag** is an analogue of a "tick" with built-in "yes" and "no" values. Useful if you are planning a one-time activity.&#x20;

> **An array** is a collection of data (numbers or strings).&#x20;
>
> It has the format: \["element 1", "element 2", "element 3", "element 4"] - square brackets, within which each element is written in quotation marks and separated by commas.&#x20;
>
> The array can store promotional codes for issuance, names of participants in a certain game, and many other useful things :)&#x20;

> **A dictionary** is a collection of key-value data pairs.&#x20;
>
> Dictionary format: {"key": "value", "key 2": "value 2"} - curly braces, double quotes for keys and values ​​(except for values ​​expressed as numbers) and separated by commas.

Thus, you can add to the array: "car, plane, ship"; and in the *dictionary*: “3 cars, 4 planes, 2 ships” and change their number right along the chain.

\
If you write it in the correct format, it will look like this: \
\["car", "aircraft", "ship"] into an array. \
{"car": 3, "aircraft": 4, "ship": 2} - to the *dictionary*

To work with arrays and dictionaries, use [smart query](https://docs.smartbotpro.io/smartquery) - commands built into the bot, similar to a programming language.&#x20;

[More about working with dictionaries](https://app.gitbook.com/o/-M0DMiuC0q5onO-ID_le/s/vTd8XmFMqkqZga7zhLuk/)[Русский](https://app.gitbook.com/o/-M0DMiuC0q5onO-ID_le/s/vTd8XmFMqkqZga7zhLuk/ "mention")\
[And about working with arrays ](https://docs.smartbotpro.io/smartquery/function-reference#rabota-s-massivami)

Variables allow you to significantly expand the functionality and implement almost any logic of the bot's actions :muscle:&#x20;
