Variables

What are variables

Variables are placeholders for information that is part of your bot, user or conversation. Variables are defined by the platform, the skills that are installed in your bot, or by you as a flow builder. Variables hold information that can be used inside your conversations. For example, Bot is the variable that holds the title of your Bot, and Purpose holds the description. Both fields are maintained on the Identity within your bot's settings.

Variables in Flows

Variables tab

The Variables tab shows the variables that can be used inside your flows. The platform variables and the built-in variables of your installed skills are displayed at the bottom. The variables that you defined yourself, called Custom variables, are displayed at the top.

Platform and built-in variables

Depending on the skills installed in your bot, the list of built-in variables might differ. The following table describes the most commonly used ones:

Label
Bubblescript
Description

Bot

bot.title

Name of the Bot as given in the Bot identity settings page.

Bot language

bot.locale

The main language of the Bot as configured in the Bot identity settings page.

Email

user.email

The email address of the user

First name

user.first_name

The first name of the user

Last name

user.last_name

The last name of the user

Language

user.locale

The language of the user, on the phone and WhatsApp channels this is derived from the country code in the phone number. On web channels it is derived from the web browser.

Last seen

user.last_seen

The datetime when the user had their last conversation with this Smart App

Last message

last_message

Last message of the user

Phone

user.phone

The phone number of the user in ISO 164 format, like +3112345678

Purpose

bot.purpose

The description of the Bot as given in the Bot identity settings page.

Conversation language

conversation.locale

The language in which the current conversation is being held. If this Smart App supports the language of the user, it will initially be the same value as the Language variable.

Using variables in your flows

There are two ways of using variables inside your flows.

Method 1 - Copy the variable to your clipboard

Click on one of the variables in the Variables tab to copy it to your clipboard. You can then paste the variable inside any of the compatible text fields of your Flow to use the selected variable.

Using variables by clipboard

Method 2 - Select the variable with short key /

Type a / (forward slash) in the text field you want to use a variable and select the variable from the drop down.

Using variables by short key /

Creating custom variables

Custom variables can be created implicitly while assigning them to a flow node or explicitly by adding a new variable in the Variables tab.

Method 1 - Create a new variable in the Variables tab

New variables can be created using the Add button in the Variables tab.

Click Add
Fill in the form

The Add button will pop up a small form to define the variable details. The following details can be defined.

Property
Description
Explanation

Label

Display name of the variable

Name

Technical name of the variable

This is the identifier of the variable used in the underlying bubblescript.

Type

Data type

To help the system understand what type of data can be stored in this variable. Choices are string, boolean, number, datetime, date.

Description

To explain the purpose of the variable

Method 2 - Create a variable while assigning

You can also store the results of an Ask node by defining it directly in a node. For example, the Ask Open node allows you to ask an open question to the user. You can capture their response by defining a new variable in the Assign to field.

Defining by assigning a variable

When a variable is created in this way, it will not have any of the other variable properties such as label, description and type. To add these later you can go to the Variables tab and click on the Edit button.

Edit the Variable details

Native string interpolation

Older skills are configured using native string interpolation using the elixir syntax. This still works for backwards compatibility reasons. Please migrate your flows to the new method whenever possible.

Data captured in variables can also be used in your flows using the native elixir string interpolation syntax:

#{variable}

In the following example the name field is captured using the Ask Name node and then the next step is a node type say which embeds the name in the text: "Nice to meet you #{name}".

Embedding user variables

Fields that are stored in the user object can be embedded by using the user object reference syntax. For instance embedding the name of the user in a text:

#{user.first_name}

Last updated

Was this helpful?