Variables in Botmother

Basic information about variables in Botmother

Basic information on variables in Botmother

If you make a bot, you will quickly get tired of sending just a text. Maybe you’d like to ask the client something, write down the answer somewhere and use it in the future. Data are written into variables.

The data we write and read from a variable are called the variable value.

Each variable has a name so that we can tell one variable from another.

Each of us dealt with variables at school in math lessons. For example, when we wrote x = 2, we worked with variables. x is the variable name, and 2 is its value.

We need variables everywhere. If you make a questionnaire, a store, an information center or a support bot, you will need variables in one way or another.

The variables in Botmother consist of three important parts:

  1. Name is a string with a convenient name.
  2. Type shows Botmother what kind of variable is in front of us: a string, a number, or something else.
  3. Value is what is written into the variable. It must match the selected type.

There are basic variables for each user. We see them in the Users tab as soon as the user writes to the bot.

Users Files (images, documents, etc.) also fall into variables, they are stored for 7 days, then disappear beyond recovery. If you need access to the files received in the bot for a period of more than 7 days, all files must be saved on your device.

Variables are displayed as "Variable": "Variable value".

{
"this_user": {
"platform_id": User ID in the platform,
"platform": "Platform" 
"firstname": "Username",
"lastname": "User surname",
"full_name": "Full username",
"username": "Username in the platform",
"language": "Interface language",
"country": "Country in device settings",
"bm_id": Unique user ID in the bot,
"phone": "User's phone number, only on WhatsApp" 
},
"last_input": "The last user input"
}

Some variables take value null. It means that there is no corresponding information on this platform. For example, it often happens on Telegram and Viber, where the last name is not required.

The key variable is last_request, which appears after the request to the server and contains the response to the request.

Output of information from variables

The main user variables are located in this_user object and their values can be output in the text in this form:

User ID inside the platform: {{this_user.platform_id}}
Platform: {{this_user.platform}}
Name: {{this_user.firstname}}
First and last name: {{this_user.full_name}}
Username: {{this_user.username}}
User language: {{this_user.language}}
bm_id: {{this_user.bm_id}}

WhatsApp transmits user phone number. You can get it like this:

{{this_user.phone}}

When working on all other platforms, user phone number must be requested additionally, it is not automatically transmitted.

You can output the rest of the multilevel variables through a dot on the same principle. Нere you will find out how to do this.

To the beginning ↑