Salebot.ai
Search…
Variables
The article tells about the variables in the system, how to use them, where to use them. Demonstrate the result of their work

How to Work with Variables

Consider what variables are and how to use them when creating chat bots on the Salebot constructor.
A variable is the text that the system replaces the user input. There are more than built-in variables in the constructor. You can also name them yourself and use them for your purposes in the bot.
the #{} construct is replaced with the value of the variable. It is recommended to use to insert the value of the variable into the text.
In the "Calculator" field, you do not need to use #{}
The variable can start with a letter only, the number cannot start

How do I compare variable values?

In the connection settings, in the Variable for comparison box, type:
client_type == 3 transition if the value of the variable is 3
attachments != None transition if variable value is filled with any content
attachments == None transition if variable value is not specified
quantity_goods >= 100 transfer if quantity of goods is greater or equal to 100
quantity_goods <= 100 transfer if the quantity of goods is less than or equal to 100
The constructor understands nested variables where the value of one variable is in the name of another variable. For example: #{q#{test#{i}}

How to remove a variable from a bot?

To remove the variable (purification), in the Calculator box, type one of two:
Name_your_variable =
Name_your_variable = "
After the sign = either a space or double quotation marks.

Built-in variables

So here’s a list of built-in variables:
#{platform_id} - client id in messenger
#{client_id} - the client id in the constructor. It is passed to API calls. #{api_key} - API token. It is passed in Salebot API calls
#{messenger} - the name of the messenger where the customer came from
#{name} - the name of the interlocutor
#{full_name} - first and last name of the interlocutor
#{custom_answer} - the response received from the server specified in the 'URL field for response from the server'
#{wa_bot} - the Whatsapp number the user wrote on (it is convenient to transfer it to the CPM fields to distribute the requests between managers)
#{question} - user message
#{attachments} - url attachments to user message in JSON array format
#{order} - the contents of a user-created claim
#{order_id} - application ID(Client ID and Internal hyphen ID)
#{none} - ignore the message
#{} - inside the brackets you can specify the input field name from the connection
#{current_date} - current date in dd.mm.yyyy time zone format
#{timestamp} - current timestamp with millisecond counting
#{date_of_creation} - the date when a person was added to a bot or wrote to it for the first time
#{next_day} - tomorrow’s date in the format dd.mm.yyyy. Convenient for sending messages tomorrow.
#{message_id} - the current state of the client dialog. Status ID. By default, NONE.
#{current_time} - project time in hh:mm format
#{weekday} - day of the week as a number, Monday - 1, Tuesday - 2
#{attachment_url} - this variable contains an embedding reference
#{client_type} - the type of messenger the client came from. The variable is simply a number.
#{avatar} - a link to the user avatar (which is displayed in the Clients section)
#{group} - the bot to which the client is bound (In the client card is called "Bound to bot")

Client_type values

for telegram 1
for Viber 2
for Facebook 3
for online chat 5
in WhatsApp 6
in avito 7
on Instagram 10
Jivosite 11
Telephony 13

Service variable

In addition to the built-in variables, the following variables may appear during the bot operation. You can use them in the process of bot creation. These variables appear automatically. Below are those that may be useful to you.
You can see additional service variables in the documentation. They are located in the sections that are relevant.
amo_client_id - client identifier in amo
amo_lead_id - Lead identifier in amo
amo_unsorted_id - identifier of unallocated in
amo avito_profile - link to customer profile in Avito
avito_order_id - ad identifier
avito_order_url - link to ad in Avito
bitrix_lead_id - Lead identifier in bitrix
bitrix_deal_id - transaction identifier in bitrix phone - phone number
notSubscribed - if the variable is 1, the client has unsubscribed from the messages and no message will be sent to it
clientBlocked - the client is locked and the bot is not working for it
story_url - Identifier storis, to which the client answered in Instagram
viewed_page - page from which a person writes in online chat wa_bot - the phone number of the bot

How to Use Variables

Variables can be used in conditions, applications, user responses, blocks, etc. Let’s look at a specific example when creating a funnel for a real estate agency.
So, we will create a welcome message and after 2 seconds we will ask the user’s name.
Then we create another block, where we thank the user for the provided information. If you switch to this block, turn on the switch "User enters data" and in the field "Input data" write "Name". In our case, "Name" is the variable into which the bot will write the user name. There can be any word both in Russian and in English, including numbers.
We can then use the input data. In the next block, we thank the user and address him by name, using our variable, without forgetting to add brackets and a grid. It looks like this: Thank you, #{Name}! Now let’s complicate the task. In the same block we will ask the user, he is interested in primary or secondary housing and add two blocks. The conditions for moving into the first block are the answer "Primary", in the second - "Secondary".
Now consider the second variant of using variables: in blocks. To do this, select the left block, click on "Advanced settings" and in the field "Calculator" enter the following text: "Client interests = Primary flats". Enter this without quotation marks. In the right block correspondingly "Clients interested = Secondary flats"
What this is for: when you switch to any of the blocks, the user is assigned a variable that we can use when creating a request. Next in the blocks let’s ask the price range for real estate. And from these blocks, let’s create a condition with validation of the entered data through the built-in variable #{question} (in this case this variable is the user’s input response) well in the same arrows let’s assign the variable "Budget".
Now more about how it will work: the built-in "question" variable contains the user’s answer. We take the user’s answer and compare it. If the number entered by him is more than 1 million, then it goes to the right, if less then to the left. We also assigned our user’s answer a new variable and called it "Budget" to make the final application look clear and beautiful. Now let’s change the type of the last two blocks to "End of data collection" and see what happened
The final bid with all the information comes to your Email
Now you can use variables in at least three different ways:
1. Assign variable names ("Name", "Budget") to the data entered by the user
2. Assign the variable name when moving to the block (Client interested = Primary housing)
3. Compare variables with a user’s answer (question >= 1000001)

How to View Variables

Variables can be viewed in the Lead section and by clicking the details in the client menu
You can edit them by clicking on them. Each variable from a new row is separated from the value by a symbol =

What Client Variables to set

Variables after "Red block" (end of data collection) DO NOT disappear.
For example client.age = 28
Client variables are used in the same way as normal variables.
How to Assign a Variable to a Client
To assign a variable to a client, you must use the client prefix before the client variable name.
Or you can use the method
set_client_var(client_id, variable, value)
where client_id - client id in Salebot
variable - the name of the variable to be assigned
value - the value of this variable
In the desired block you place it in the field "Calculator", filling parameters variable and value.
Example: set_client_var(client_id, "new", "yes")

How to Set Common Variables

Common variables are available to all users of the bot. They can be used to control the bot or to communicate between clients. For example, one client places an advertisement, everyone sees it and someone responds.
Variables after "Red block" (end of data collection) DO NOT disappear.
You can write a variable using a prefix, for example: Requests amount = 28 or project.age = 28 You can already use them without a prefix. Edit general variables in project settings:

Example of Common Variables

For example, let’s make the system assign a number to the client in order.
Initially in the general variable write 0, which means there are no clients in the bot.
Next, in the starting block of the bot, add a unit and assign the number to the client.
Do not forget to set a limit

How to Set Constant Variables

Constant variables are constant variables whose values rarely change in a project (or do not change at all). Unlike general variables, only one current client has access to them, and if the change variable is overwritten, it will apply only to that client. In constant variables you can write the cost of goods, discount for the buyer, access tokens to integrations, contact details of the seller, etc.

Example of Using Constant Variables

As an example, let’s say that the default discount for a new client is 10%, but if you enter a promotional code - becomes 25%.
In Settings - Project Editing - Project variables write Discount : 30. If you need to enter a lot of variables, it is convenient to select "Old style" and enter equals each with a new row.
To enter the promotional code, add the block "No condition with condition", where we assign the variable "Discount" value 30.
Thus, the variable "Discount" for this client after the introduction of the promotional code became 30.

Limits

Maximum variable name length: 500
Maximum variable length: 100,000
Maximum number of variables at the client or transaction: 1000
Last modified 5mo ago
Copy link
On this page
How to Work with Variables
How do I compare variable values?
How to remove a variable from a bot?
Built-in variables
Client_type values
Service variable
How to Use Variables
How to View Variables
What Client Variables to set
How to Set Common Variables
Example of Common Variables
How to Set Constant Variables
Example of Using Constant Variables
Limits