Skip links

Everything you need to know about {{…}} variables

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

1. What is a variable?

A variable is a text symbol, in the form {{Variable}}, which associates a value with this symbol. This value can be either a text or a number, such as an address, a vehicle model, a telephone 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.

Variables have no lifespan: they are stored in Botnation’s databases for as long as your chatbot is active on the platform, with no limit on their number or use. A user who only consults your chatbot once a month will still find the variables that enable you to personalize its use.

2. System variables

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

To personalize the user’s Facebook Messenger conversation:

  • First name: {{FIRSTNAME}}
  • The name: {{LASTNAME}}
  • Sex: {{GENDER}}
  • La langue : {{LANGUAGE}}  (liste des codes retournés)
  • 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}}
  • L’identifiant de la page Facebook Messenger contactée par l’utilisateur  : {{BN_MESSENGER_PAGE}}  (en savoir plus) 
  • {{NEW_LINE}}: generates a line break, useful for formatting an email using variables for example.
  • {{NEW_SPLIT}} : Automatically divides a text into several different messages (bubbles). For long texts from an API webhook call, for example.

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

  • The user’s last text entry: {{BN_USER_INPUT}}
  • The keyword or expression that triggered a sequence: {{BN_ACTIVE_EXPRESSION}}
  • Current context: {{BN_ACTIVE_CONTEXT}}
  • The HTTP status returned by your Webhook (remote server contacted). Only in ‘interpret response’ 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}} : Est égal à 1 si l’utilisateur est déjà passé dans une boucle infinie de votre chatbot.

Not all of this information is necessarily filled in, depending on the communication medium or the information entered by the user.
It’s also important to note that these system variables cannot be modified by the chatbot; they can only be consulted.

3. User variables

Unlike the previous variables, you have complete control over them. In addition to creating and viewing them, you can also modify them.

Elles sont personnelles à chaque utilisateur de votre 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 needs to ask the user the make and model of the prospect’s vehicle.

So we’ll create a variable whose name is {{marque}} and whose value is the make of 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 dedicated solely to “Renault” brand vehicles, for example, using the conditions.

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

4. Global variables

Global variables can be found in your chatbot’s advanced settings.

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

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

5. Date and time variables

La fonction “Date et heure” permet à vos utilisateurs de saisir très facilement via un calendrier visuel une date et une heure afin de renseigner au travers de votre chatbot une prise de rendez-vous,  une date de naissance, une période de réservation désirée etc…

En retour de nombreuses variables du type {{CALENDAR_DAY}} sont disponibles, la liste complète est disponible ici. 

Botnation also features system variables and functions that let you easily display, manipulate or calculate date and time.

Les variables dates sont disponibles ici.  

6. GPS-related variables

Des fonctions sont également disponibles afin de calculer facilement la distance entre des coordonnées GPS dans votre chatbot. Elles sont disponibles ici.

7. Variable handling

The main elements that manipulate user and global variables are :

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

Pour effacer ou ré-initialiser (reset) une variable il suffit de l’affecter avec du vide (rien) ou 0 dans une séquence de votre bot. Au lancement par exemple si vous avez besoin de faire des tests réguliers en partant de variables vides.

Enfin sachez qu’il est possible d’importer ou d’exporter les variables collectées dans un CRM externe comme Salesforce, votre propre base de données, un simple Google Sheet ou encore via l’élément  “Webhook”.

In this way, an order placed on your chatbot can be automatically fed back into your management system in real time.

8. Variables on video

SHARE ON