All about {{…}} variables

A variable is a powerful tool to dynamically customize your chatbot and collect data.

➜ Discover Botnation and launch your chatbot easily!

1. What is a variable?

A variable is a textual symbol, in the form {{Variable}}, which associates a value to this symbol. This value can be either a text or a number, such as an address, a vehicle model, a phone number or a quantity.

This value is dynamic and can change as many times as you want depending on the use of your chatbot.

Moreover, each variable is unique to each user of your chatbot, so two users can use variables with the same symbol, {{le_choix}}, but whose content will be different because they have neither the same model of vehicle, nor the same phone number.

The variables have no lifespan, they are stored in Botnation’s databases as long as your chatbot is active on the platform, with no limit to the number and use. A user who only consults your chatbot once a month will still find its variables at each use, allowing you to customize its use.

2. System variables

As soon as the user initiates a conversation with the chatbot, the latter will retrieve any available information from the user and store it in the value of the system variables.

To personalize the user’s conversation in Facebook Messenger:

  • First name: {{FIRSTNAME}}
  • The name: {{LASTNAME}}
  • Sex: {{GENDER}}
  • The language : {{LANGUAGE}} (list of returned codes)
  • The unique user ID: {{USER_ID}}
  • The avatar (profile picture), if available: {{PROFILEPIC}}
  • Optin on Facebook notifications (0 = no, 1 = yes): {{BN_OPTIN}}

After optin-Facebook Messenger:

  • The user’s email {{BN_EMAIL}}
  • The user’s phone number {{BN_PHONE_NUMBER}}
  • GPS coordinates and addresses (see details on interface): {{GPS_LONG}} {{GPS_LAT}} {{GPS_CITY}} {{GPS_COUNTRY}}

For more advanced use:

  • The URL of the last file sent: {{BN_URL_UPLOAD}}
  • The length of the user’s last text entry: {{BN_USER_INPUT_LENGTH}}
  • The identifier of the Facebook Messenger page contacted by the user: {{BN_MESSENGER_PAGE}}(read more)
  • {{NEW_LINE}} : generates a line break, useful for formatting an email via variables for example.
  • {{NEW_SPLIT}} : Automatically divides a text into several different messages (bubbles). For possible long texts from an API webhook call for example.

To “debug”… or understand the chatbot’s reasoning 🙂

  • The last text entry of the user: {{BN_USER_INPUT}}
  • The keyword or expression that triggered a sequence: {{BN_ACTIVE_EXPRESSION}}
  • The current context: {{BN_ACTIVE_CONTEXT}}
  • The Http status returned by your Webhook (remote server contacted). Only in “interpret the answer” mode: {{BN_WEBHOOK_STATUS}}
  • The error message returned by your webhook or if the json transmitted in return is incorrect: {{BN_WEBHOOK_REASON}}
  • {{BN_INFINITE_LOOP}} : Is equal to 1 if the user has already passed through an infinite loop of your chatbot.

All this information is not necessarily filled in, it will depend on the communication medium or the information filled in by the user.
You should also know that these system variables cannot be modified by the chatbot, they can only be consulted.

3. User variables

Unlike the previous variables, you have full control over these variables. In fact, in addition to creating and consulting them, you can modify them.

They are personal to each user of your chatbot.

You can create user variables from a “User input” element.

Let’s take a simple example:

Let’s create a chatbot for a car mechanic who will need to ask the user the make and model of the prospect’s vehicle.

We will therefore create a variable whose name is {{marque}} and whose value is the make of the vehicle entered by the user. The same goes for the {{model}}. To retrieve the information, simply consult the value of the variable named {{marque}}.

This data can be used to display promotions only dedicated to “Renault” brand vehicles for example by using the conditions.

By automatically incrementing a variable {{passage}} at each conversation launch you can also display a message or a promotion dedicated to the most active users of your chatbot.

4. Global variables

The global variables can be found in the advanced settings of your chatbot.

Global variables are common to all users of your chatbot. You can store the customer service phone number, the price of an item on sale. In short, information that is identical regardless of the user.
They are loaded by default (no need for a setup in the scenario) and can be modified via the interface if there are changes to be made.
So if a rate changes, it is changed for all users without any action required for each user.

They are displayed in the form {{My_Global_Variable}} and are automatically available in the variable lists in the interface.

5. The variables related to Dates and Time

The “Date and time” function allows your users to easily enter a date and time via a visual calendar in order to inform your chatbot of an appointment, a birth date, a desired reservation period, etc.

In return many variables of the type {{CALENDAR_DAY}} are available, the complete list is available here.

Botnation also offers system variables and functions that allow you to easily display and manipulate or calculate the date and time.

The date variables are available here.

6. The variables related to the GPS

Functions are also available to easily calculate the distance between GPS coordinates in your chatbot. They are available here.

7. Handling of variables

The main elements that manipulate user and global variables are the following:

  • User input
  • Condition
  • Assign
  • Increment
  • Decrement
  • Random
  • Calculation
  • Manage Breakage
  • Concatenate
  • Replace

To erase or reset a variable you just have to assign it with empty (nothing) or 0 in a sequence of your bot. At launch, for example, if you need to run regular tests starting from empty variables.

Finally, it is possible to import or export the variables collected in an external CRM such as Salesforce, your own database, a simple Google Sheet or even via the “Webhook” element.

Thus, an order placed on your chatbot can be automatically sent to your management system in real time.

➜ Discover Botnation and launch your chatbot easily!