Variables

In this section, we will look at what variables are in Smartbot Pro.

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 .

Variables are keys in the format %variable_name% that will be replaced by the bot with variable values ​​in the message text or condition.

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

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.

User variables

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

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.

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.

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

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

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

An array is a collection of data (numbers or strings).

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.

The array can store promotional codes for issuance, names of participants in a certain game, and many other useful things :)

A dictionary is a collection of key-value data pairs.

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 - commands built into the bot, similar to a programming language.

Last updated