Manage Variables
Variables
Variables or properties or entities are data storage entities. Variables are a way to store data or the user input in a format to reuse that detail in the chatbot conversation or to store the information.
Variables are helpful when you need to personalize the conversation by saving the user name in a variable for using it during the conversation or if you want to store user details and pass them on to external systems or generate reports.
You can save user details or inputs in a variable for getting user insights as well.
Types of Variables
Generally, these are of the below kinds:
- System - These are generally global contexts, not under the direct control of a brand. For eg, the current date, and time. These variables are provided by Bot Studio and can not be modified. They are available for read only use.
System Variable | Use | Example |
---|---|---|
event_type | Stores the event type. Events can be user inputs(user_input), marketing campaign(marketing_campaign), click to chat ad(click_to_chat_advertise) events. | user_input |
channel | Stores the channel on which user is interacting with the bot | |
user_channel_id | Stores the unique channel id of the user interacting with the bot. If the channel is whatsapp, user_channel_id contains the country code + Ten digit user number | 91XXXXXXXXXX |
user_input | Stores the last user input received | If user selects a button "next" on reply node, user_input contains "next" |
timeStampEpoch | Stores the Epoch timezone format | 1648796400 |
payloadString | Contains entire payload of user's conversation | {"source":"channel","sender":"91XXXXXXXXXX","channel":"whatsapp","isGroup":false,"isFromDocker":false,"destination":917669715082,"botname":"LXNkW5hNhNMVG55amn2PvjMG","proxy":false,"contextobj":{"channeltype":"whatsapp","contexttype":"p2p","contextid":"91XXXXXXXXXX","botname":"LXNkW5hNhNMVG55amn2PvjMG","preventReply":false,"senderName":"****","cc":"91","dc":"XXXXXXXXXX"},"senderobj":{"channeltype":"whatsapp","channelid":"91XXXXXXXXXX","display":"****"},"messageobj":{"refmsgid":"5db41b09-4df4-42ae-8e27-5273b15b1edc","metadata":{"flowId":"68B31B92D79E2AC-000000000000478B"},"type":"text","text":"Next","from":"91XXXXXXXXXX","timestamp":1689155106659,"raw":{"id":"ABEGkYgAYEg4Ago6TIBLpqKKmiqU","source":"91XXXXXXXXXX","payload":{"title":"Next","id":"5db41b09-4df4-42ae-8e27-5273b15b1edc","reply":"Next 1","postbackText":"Next"},"sender":{"phone":"91XXXXXXXXXX","name":"****","country_code":"91","dial_code":"XXXXXXXXXX"},"context":{"id":"gBEGkYgAYEg4AgmW62X91r_RXEM","gsId":"5bcc56ba-5605-47ea-ade5-545aac70fc5b"},"type":"button_reply"},"id":"ABEGkYgAYEg4Ago6TIBLpqKKmiqU","postbackText":"Next"},"isFromSendMessage":false,"disableForwarding":false,"disablePreview":false,"event_type":"user_input","context":{"channeltype":"whatsapp","contexttype":"p2p","contextid":"91XXXXXXXXXX","botname":"LXNkW5hNhNMVG55amn2PvjMG","preventReply":false,"senderName":"****","cc":"91","dc":"XXXXXXXXXX"},"message":"Next","postbackText":"Next"} |
user_name | Contains user name | Jane Doe |
- Global Session - These are brand-level variables. They are defined by the brand and have the same value across all end users. For example, counter, brand name, etc.
- Local Session - These variables are global for a customer/end user. For example, customer name, email address, etc.
- Local or Session-based - These are session-based variables, whose scope can restrict to a particular session. For eg, after the 24-hour session on WhatsApp, the local variables can restart again
- Event-based - These are external variables whose scope is customer based but can be true for a segment of customers. For example, the channel of the message received from the customer, customer message, type of events, autoresponders, etc. These can be viewed or used but should not be edited.
Variable Management Elements
- Name (Unique identifier)
- Data Type (the kind of data it can store, for eg, text, number)
- Dummy Value (Some initial value for eg, 0 for a number or another constant)
Data Types
There are three data types that can be stored:
- Number
- String
- JSON
How to use a variable
Below are the steps to use variables in the chatbot journey building:
- Open the Variable Management screen. (you can open the Variable Management screen by clicking on Manage Variables)
- Give a name to the variable, eg - user_phone, user_email
- Select the data type from the dropdown on the manage variable screen.
- Provide a default value (it is optional) and click save.
Limitations
- Any special character can’t be added to the variable name except _ and -
- Duplicate name variables can’t be added.
- System Variable and Session Variable Naming can’t be the same.
How to use
Variables can be added by clicking on Manage Variable Button on the Journey Builder screen. Any Variable added can't be deleted, only the default value can be edited for a variable. To add a variable, a Name, and Data type are to be added and then click on the save button.
Variable Management Screen
NOTE:
If the 'Default Value' is not provided by the user, then the platform sets the following default values as shown:
- String: empty string ""
- Number: 0
- JSON : empty Object {}
Updated 3 months ago