Custom Variables

Custom Variables allow you to work with the information your bot has gathered.



To see a working example of a chatbot that uses custom variables to keep track of sales, please go to the SnatchBot Store and choose to edit the Pizza Bot Template.

You will need Custom Variables when you want your bot to be able to work with information it has gathered and, in particular, if you want to perform arithmetic functions during the course of the conversation.

For example, if you are designing a chatbot that can take payments and which calculates a running total, then the bot will store the figures it is adding up using the Custom Variables function.


Unlike Attributes, Custom Variables are stored temporarily: this means that if a user updates a webpage or restarts your bot, then all collected values will be reset.

Set Value

Each Custom Variable has a name and a value. In order to define a CV select Custom Variables->Set Value. The following function will appear in the interaction:

[customVar KEY=VALUE]

KEY - KEY is the name you give the variable e.g. Total Bill.
VALUE - Value is the initial content of the variable

Replace the 'KEY' and 'VALUE' with the data you need. For example: [customVar X=5] or [customVar First_Name=John]



Only alphanumeric names (English letter) are allowed in Attribute KEY names, please don't use special symbols.

Get Value

If you want to show a user some value of a Custom Variable during the conversation, for example, the total of their purchases, you should place this function in an interaction:


KEY must refer to a Custom Variable you have already defined. So, for example [ShowVar=Total_Bill] will not work unless you have defined [customVar Total_Bill=x] first.



Do not use the ‘Set value’ and ‘Get value’ functions or use the same variable twice within the same interaction. It may lead to errors!

As always, we have provided a shortcut to inserting functions. customVar and showVar can be found above the Bot Message field, as drop-down options under Custom Variables:


You can assign a random value to your Custom Variable, using the following type of construction:

[customVar random={3}{4}{5}{6}{7}]. This will cause the Custom Variable to have a value of 3, 4, 5, 6 or 7, chosen randomly.

The value of the Custom Variable is typically going to be a number, but you can also define it as statement (a word, characters, or even sentences) or you can assign to it values from responseTo or extractedData.

To use the user's response to any previous interaction as the value of your Custom Variable insert a Prior Response formula as it is shown below:.


Watch this video tutorial ''How to deal with Custom Variables on the SnatchBot platform''

Next Steps

User Attributes are personal tags or labels that get assigned to each user interacting with your bot.