{"id":22120,"date":"2022-09-05T13:46:39","date_gmt":"2022-09-05T11:46:39","guid":{"rendered":"https:\/\/botnation.ai\/support\/everything-you-need-to-know-about-variables\/"},"modified":"2026-11-14T19:44:45","modified_gmt":"2026-11-14T18:44:45","slug":"everything-you-need-to-know-about-variables","status":"publish","type":"support","link":"https:\/\/botnation.ai\/en\/support\/everything-you-need-to-know-about-variables\/","title":{"rendered":"Everything you need to know about {{&#8230;}} variables"},"content":{"rendered":"<p class=\"wp-block-paragraph\">A variable is a powerful tool to dynamically customize your chatbot and collect data.<\/p>\n\n<h2 class=\"wp-block-heading\">1. What is a variable?<\/h2>\n\n<p class=\"wp-block-paragraph\">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. <\/p>\n\n<p class=\"wp-block-paragraph\">This value is dynamic and can change as many times as you want depending on the use of your chatbot.<\/p>\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n<p class=\"wp-block-paragraph\">Variables have no lifespan: they are stored in Botnation\u2019s 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. <\/p>\n\n<h2 class=\"wp-block-heading\">2. System variables<\/h2>\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n<p class=\"wp-block-paragraph\"><strong>To personalize the user\u2019s Facebook Messenger conversation:<\/strong><\/p>\n\n<ul class=\"wp-block-list\"><li>First name: {{FIRSTNAME}} <\/li><li>The name: {{LASTNAME}}<\/li><li>Sex: {{GENDER}}<\/li><li>La langue : {{LANGUAGE}} \u00a0<a href=\"https:\/\/botnation.ai\/fr\/?post_type=support&amp;p=399\">(liste des codes retourn\u00e9s)<\/a><\/li><li>The unique user ID: {{USER_ID}}<\/li><li>The avatar (profile picture), if available: {{PROFILEPIC}}<\/li><li>Optin on Facebook notifications (0 = no, 1 = yes): {{BN_OPTIN}} <\/li><\/ul>\n\n<p class=\"wp-block-paragraph\"><strong>After optin-Facebook Messenger<\/strong>:<\/p>\n\n<ul class=\"wp-block-list\"><li>The user\u2019s email {{BN_EMAIL}}<\/li><li>The user\u2019s phone number {{BN_PHONE_NUMBER}}<\/li><li>GPS coordinates and addresses (see details on interface): {{GPS_LONG}} {{GPS_LAT}} {{GPS_CITY}} {{GPS_COUNTRY}}<\/li><\/ul>\n\n<p class=\"wp-block-paragraph\"><strong>For more advanced use :<\/strong><\/p>\n\n<ul class=\"wp-block-list\"><li>The URL of the last file sent: {{BN_URL_UPLOAD}}<\/li><li>The length of the user\u2019s last text entry: {{BN_USER_INPUT_LENGTH}} <\/li><li>L\u2019identifiant de la page Facebook Messenger contact\u00e9e par l\u2019utilisateur \u00a0: {{BN_MESSENGER_PAGE}} \u00a0(<a href=\"https:\/\/botnation.ai\/en\/support\/managing-multiple-facebook-pages-on-a-single-messenger-chatbot-2\/\">en savoir plus<\/a>)\u00a0<\/li><li>{{NEW_LINE}}: generates a line break, useful for formatting an email using variables for example.<\/li><li>{{NEW_SPLIT}} : Automatically divides a text into several different messages (bubbles). For long texts from an API webhook call, for example. <\/li><\/ul>\n\n<p class=\"wp-block-paragraph\"><strong>To \u201cdebug\u201d\u2026 or understand the chatbot\u2019s reasoning \ud83d\ude42 <\/strong><\/p>\n\n<ul class=\"wp-block-list\"><li>The user\u2019s last text entry: {{BN_USER_INPUT}}<\/li><li>The keyword or expression that triggered a sequence: {{BN_ACTIVE_EXPRESSION}}<\/li><li>Current context: {{BN_ACTIVE_CONTEXT}}<\/li><li>The HTTP status returned by your Webhook (remote server contacted). Only in \u2018interpret response\u2019 mode: {BN_WEBHOOK_STATUS}<\/li><li>The error message returned by your webhook or if the json transmitted in return is incorrect: {{BN_WEBHOOK_REASON}}<\/li><li>{{BN_INFINITE_LOOP}} : Est \u00e9gal \u00e0 1 si l\u2019utilisateur est d\u00e9j\u00e0 pass\u00e9 dans <a href=\"https:\/\/botnation.ai\/en\/support\/why-does-an-infinity-symbol-%e2%88%9e-appear-2\/\">une boucle infinie<\/a> de votre chatbot.<\/li><\/ul>\n\n<p class=\"wp-block-paragraph\">Not all of this information is necessarily filled in, depending on the communication medium or the information entered by the user.<br>It\u2019s also important to note that these system variables cannot be modified by the chatbot; they can only be consulted.<\/p>\n\n<h2 class=\"wp-block-heading\">3. User variables<\/h2>\n\n<p class=\"wp-block-paragraph\">Unlike the previous variables, you have complete control over them. In addition to creating and viewing them, you can also modify them. <br><br>Elles sont personnelles \u00e0 chaque utilisateur de votre chatbot. <\/p>\n\n<p class=\"wp-block-paragraph\">You can create user variables from a \u201cUser input\u201d element.  <\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"476\" height=\"508\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-70.png.webp\" alt=\"\" class=\"wp-image-519\" srcset=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-70.png 476w, https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-70-281x300.png 281w\" sizes=\"(max-width: 476px) 100vw, 476px\" \/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\"><strong>Let\u2019s take a simple example:<\/strong><br><br>Let\u2019s create a chatbot for a car mechanic who needs to ask the user the make and model of the prospect\u2019s vehicle.<\/p>\n\n<p class=\"wp-block-paragraph\">So we\u2019ll 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}}.  <\/p>\n\n<p class=\"wp-block-paragraph\">This data can be used to display promotions dedicated solely to \u201cRenault\u201d brand vehicles, for example, using the conditions.<\/p>\n\n<p class=\"wp-block-paragraph\">By automatically incrementing a {{passage}} variable at each conversation launch, you can also display a message or promotion dedicated to your chatbot\u2019s most active users.<\/p>\n\n<h2 class=\"wp-block-heading\">4. Global variables<\/h2>\n\n<p class=\"wp-block-paragraph\">Global variables can be found in your chatbot\u2019s advanced settings.<\/p>\n\n<p class=\"wp-block-paragraph\">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.<br>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.<br>So if a price changes, it is changed for all users, without any action being required for each user.  <\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"463\" height=\"369\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-71.png.webp\" alt=\"\" class=\"wp-image-521\" srcset=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-71.png 463w, https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-71-300x239.png 300w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/figure>\n<\/div><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"359\" height=\"178\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-72.png.webp\" alt=\"\" class=\"wp-image-523\" srcset=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-72.png 359w, https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-72-300x149.png 300w\" sizes=\"(max-width: 359px) 100vw, 359px\" \/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">They are displayed as {{%%My_Global_Variable%%}} and are automatically available in variable lists in the interface.<\/p>\n\n<h2 class=\"wp-block-heading\">5. Date and time variables<\/h2>\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/botnation.ai\/en\/support\/capture-a-date-3\/\">La fonction \u201cDate et heure\u201d<\/a> permet \u00e0 vos utilisateurs de saisir tr\u00e8s facilement via un calendrier visuel une date et une heure afin de renseigner au travers de votre chatbot une prise de rendez-vous, \u00a0une date de naissance, une p\u00e9riode de r\u00e9servation d\u00e9sir\u00e9e etc\u2026<\/p>\n\n<p class=\"wp-block-paragraph\">En retour de nombreuses variables du type {{CALENDAR_DAY}} sont disponibles, la liste compl\u00e8te est <a href=\"https:\/\/botnation.ai\/en\/support\/capture-a-date-3\/\">disponible ici<\/a>.\u00a0<\/p>\n\n<p class=\"wp-block-paragraph\">Botnation also features system variables and functions that let you easily display, manipulate or calculate date and time.<\/p>\n\n<p class=\"wp-block-paragraph\">Les variables dates <a href=\"https:\/\/botnation.ai\/fr\/support\/date-variables-et-fonctions\/\">sont disponibles ici<\/a>. \u00a0<\/p>\n\n<h2 class=\"wp-block-heading\">6. GPS-related variables<\/h2>\n\n<p class=\"wp-block-paragraph\">Des fonctions sont \u00e9galement disponibles afin de calculer facilement la distance entre des coordonn\u00e9es GPS dans votre chatbot. <a href=\"https:\/\/botnation.ai\/en\/support\/beta-gps-tools-3\/\">Elles sont disponibles ici.<\/a><br><\/p>\n\n<h2 class=\"wp-block-heading\">7. Variable handling<\/h2>\n\n<p class=\"wp-block-paragraph\">The main elements that manipulate user and global variables are :<\/p>\n\n<ul class=\"wp-block-list\"><li>User input<\/li><li><a href=\"https:\/\/botnation.ai\/en\/support\/the-if-condition-feature\/\">Condition<\/a><\/li><li>Assign<\/li><li>Increment<\/li><li>Decrement<\/li><li>Random<\/li><li>Calculation<\/li><li>Managing Breakage<\/li><li>Concatenate<\/li><li>Replace<\/li><\/ul>\n\n<p class=\"wp-block-paragraph\">Pour effacer ou r\u00e9-initialiser (reset) une variable il suffit de l\u2019affecter avec du vide (rien) ou 0 dans une s\u00e9quence de votre bot. Au lancement par exemple si vous avez besoin de faire des tests r\u00e9guliers en partant de variables vides.<br><br>Enfin sachez qu\u2019il est possible d\u2019importer ou d\u2019exporter les variables collect\u00e9es dans un CRM externe comme Salesforce, votre propre base de donn\u00e9es, un simple <a href=\"https:\/\/botnation.ai\/en\/support\/importing-and-exporting-google-sheets-data-into-your-chatbot-2\/\">Google Sheet<\/a> ou encore via <a href=\"https:\/\/botnation.ai\/en\/support\/api-botnation-importing-and-exporting-data-via-webhook\/\">l\u2019\u00e9l\u00e9ment \u00a0\u201cWebhook\u201d.<\/a><\/p>\n\n<p class=\"wp-block-paragraph\">In this way, an order placed on your chatbot can be automatically fed back into your management system in real time.<\/p>\n\n<h2 class=\"wp-block-heading\">8. Variables on video<\/h2>\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"chatbot : utiliser des variables avec BotNation.ai\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/2MKLoyJcRis?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"featured_media":0,"template":"","meta":{"_acf_changed":false},"categorie-support":[194,222,221],"class_list":["post-22120","support","type-support","status-publish","hentry","categorie-support-features","categorie-support-variables-en","categorie-support-web-chatbot-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support\/22120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support"}],"about":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/types\/support"}],"wp:attachment":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/media?parent=22120"}],"wp:term":[{"taxonomy":"categorie-support","embeddable":true,"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/categorie-support?post=22120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}