Copied +55 (21) 960104492
Log In Free trial
Select region

Variables and constants

A variable is a data storage to which we assign a name. And then we fill this storage with data and can use it, for example, to address a client by name in a bot.

Functions of variables and constants

Local, system, and global variables and constants are available in the constructor. Local, global, and constants can be created and modified manually, system variables cannot.

Systemic

Data in this variable appears at the moment of receiving a message from the client. System variables contain information about the dialogue:

  • company_id — The id of your company to which the message came.
  • email — The mail address from which the message came
  • license_id — The line to which the message came
  • message — Text of the client's message
  • messenger_type -— The channel from which the message came (instant messenger or e-mail).
  • name - Client's name (the name is set as in ChatApp Dialog).
  • phone - Phone number from which the message came.
  • responsible - Employee responsible for the dialogue.
  • username - Username of the client.
  • date - Date.
  • day_of_week - Day of week.
  • time - Time.

System variables of date and time can be used separately from the client's message. If there is no message from the client, then the present date and time of the UTC +3 zone are taken, if there is a message, then it is taken from the time zone of your company.

Local

The value of this variable is unique for each dialogue. For example, if the bot has two dialogues simultaneously, changing a local variable in one dialogue will not affect the value of the same variable in the other dialog.

A local variable can be created and changed. Here's how to do it:

1. Go to the Bot Editor;

2. Click "Variables" in the right corner;

3. Click on or on an existing variable;

4. Select the data type;

5. Enter a name and value (you can save with an empty value);

6. Click "Save".

Global

The value of the global variable is the same for all dialogs. It can be created and changed. The global variable is, for example, the line or messenger in which the bot is currently communicating.

Here's how to create it:

1. Go to the Script Editor;

2. Click "Variables" in the corner on the right;

3. Click on or on existing variable;

4. Select the type of variable;

5. Select the data type;

6. Enter a name and value;

7. Click “Save”.


Constant

A constant is a value that remains unchanged during program execution. Its properties are the same as the global one, but it cannot be changed during the dialog.

Using variables in text

In the editor, you can use variables in the message text. A variable is denoted by double brackets {{var}} and the value from the variable is substituted in its place. Any existing variable can be used as a variable.

The use of variables is available in the following blocks:

  • Sending a message;
  • Sending a message*;
  • Sending webhook;
  • Open dialogue;
  • Close dialogue.

The list of blocks that support variables will be enlarged. We are actively working on it.

If a local or system variable is selected, but the value is not available, nothing will be inserted.

Video tutorial

Leave a request for integrator services