Skip to main content

Variables

"Variable" is temporary storage for your data. They can be used for storing data fetched from the end-user. Moreover, you can also use variables to validate if the end-user is a first time user and much more.

Why user Variables?

Suppose you have a script in which you ask the end-user, their age. You may use their age to show products that are relevant to that age group. However, you cannot implement this flow unless you store the incoming data from the user (age), somewhere, so you can use it later. Variables come in handy at this time, you can create a variable and store the user age in that variable, later you can validate the value of that variable ( by using this element). 

Variable Types

RepliedAI uses two types of variables
  1. System variables.
  2. User Variables.

System Variables

System variables are pre-defined variables. You can use the following "System Variables"

  1. _UserName :  This variable stores the end-user name if they have configured any. If the end-user has not configured any name, this variable will have a default value 'user'
  2. _CatalogueItem : This variable stores the product ID of the selected product from the conversation element "Product Catalogue". This variable will only be populated if the "product catalogue" is displayed. If the end-user clicks on any of the items in the catalogue, this variable gets populated with the product id of that variable. You can then validate this variable using this element to confirm the value of the product ID.
  3. _FirstTimeUser : This variable will have a value 'true' if the end-user is using your chatbot for the first time. If the end-user is a returning user the variable will have a value of 'false'. 
  4. _UserRegister1  :  This variable does not have an initial value. This can be used by you to store any information. Since this variable is
    "User variable" and "_UserRegister1" are used by you to store the information, this variable(_UserRegister1) is unique in a way that it does not require to send any message to the user, unlike the other user-defined variables. 

User Variables

User variables are created by the user(you) to store any information fetched from the end-user.

Configuring user variables:

User-defined variables always store the information provided by your end-user, that is the reason all user-defined variables need to start with a query statement based on which, end-user will provide the information. 

These variables can be declared by following these steps. 
  1. Log into repliedAI console click here.
  2. Navigate to the "My bots" section. 
    Create your bot

  3. If you have not created any bot yet, follow this tutorial to create your first bot click here. If you already have a bot then go to the bot design studio by clicking on this button. 

  4. Once you are in the bot design studio, add conversation Element "Save user input" into your chatbot design.
    Save user input



  5. Click on the cog icon over the "Save user input" conversation element, this will take you to the user-defined variables settings page
    Variable setting button

  6. On the user-defined variables settings page, type in the required information:
    • User prompt: Type the question or statement that will prompt end-user to provide the information
    • Data Field Name: This is the name of the variable, type-in a unique name so that you can reference it later.
    • Data Retained For Type the number of days up to when you want the data to be retained. e.g. if you type 1, then the data will be retained for 1 day.


Comments