Comment on page


Variables are used to store any information the bot knows about a user. This can be their preferred language, or the channel they're using, but also information coming from external data sources like, for example, an API. All variables are stored in what is called a user's session.

Variables menu

Create a variable

To create a variable from the Settings tab:
  1. 1.
    Click on Variables.
  2. 2.
    Click on Create Variable.
  3. 3.
    A window pops up. Fill in the fields with what you want.
  4. 4.
    Save your changes.
Create a variable from the Settings tab.

Set a variable as sensitive

Chatlayer allows you to make sure that some variables are processed differently. This is useful when the conversation between a bot and a user contains sensitive information, such as the user's bank account number or anything GDPR-sensitive.
To define a variable as sensitive:
  1. 1.
    Open your Variables menu under the Settings tab.
  2. 2.
    Toggle on the Sensitive switch if you don't want this variable to be saved in the conversation history.
  3. 3.
    Save your changes.
Create a sensitive variable from the Settings tab.
If you put the Sensitive toggle to true, the values of your variable will never be shown in Chatlayer. Instead, any user of our platform will only see a placeholder with the variable name. This information can only be retrieved through an API request.

Terminology and behaviour

Default value

You can set default values for variables, which serve as initial values for these variables. For example, default value can be used to define the path to a URL for making API calls. This ensures for example that the chatbot always has the correct URL to fetch data or interact with external services.

Data Type

Default values are limited to string data types.

Publishing Behavior

When publishing changes to the chatbot, new values are only set for variables if previous values did not exist for those variables. If there were previous values, they are retained.

Clear Session Template

When using the clear session template, the value for a variable will be reset to its default value if it had been modified during the session.

Operations on variables

Increment a variable

If you want to incrementally increase the value of a variable, you can use the following steps:
  1. 1.
    Define a variable, for example variableName, and give it a numeric value such as 0
  2. 2.
    At the point in the flow where you want to increment the value of variableName, enter variableName as the variable and {variableName|increment} as the value
This method will increase the value of counter by 1 each time, for example when a specific bot dialog is passed or a button is clicked.
Incrementing a variable can be typically useful when you want to count how many times the user wasn't understood by the bot. Learn how to build a Not Understood Counter here.

Change the variable case

Variables and values are case-sensitive.
For example, capitalVariable will be regarded as a separate variable fromCapitalVariable.
The same goes for values. If you check in a Go To if a value for variableX is equal to valueY it will not be triggered if the value for variableX is equal to valuey
You can transform a value from upper case to lower case and vice versa by adding these modifiers to the value name: