Variables in Botmother

Basic information about variables in Botmother

In the builder, you can store and use not only static information but also variable information depending on the data entered by a user. The values that are changed are called variables.

There are basic variables for each user. We see them in User State section 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.