Manage Variables

Variables

The Journey Builder Platform empowers bot designers to create interactive and dynamic conversational experiences. Within this platform, variables play a crucial role in storing and managing data. There are three primary types of variables in the Journey Builder Platform: System Variables, Global Variables, and Local Variables. Each type serves a specific purpose in designing and customizing bot interactions.

Types of Variables

  1. System Variables - System Variables are predefined and maintained by the Journey Builder Platform itself. They are automatically created, and updated with each user interaction, making them integral for tracking user inputs and system states. System Variables cannot be modified directly by bot designers, as their values are determined by the user's actions and the bot's internal logic.
System VariableUseExample
event_typeStores 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
channelStores the channel on which user is interacting with the botwhatsapp
user_channel_idStores 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 number91XXXXXXXXXX
user_inputStores the last user input receivedIf user selects a button "next" on reply node, user_input contains "next"
timeStampEpochStores the Epoch timezone format1648796400
payloadStringContains 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_nameContains user nameJane Doe
  1. Global Variables - Global Variables are user-defined variables that offer flexibility in managing data throughout the bot's lifecycle. Bot designers can create global variables and set their default values. These variables can also be updated dynamically during bot runtime, enabling designers to adapt to changing user contexts and requirements. Global Variables are accessible from any journey within the bot, making them valuable for maintaining consistency and sharing data across different parts of the bot.
    Example:
    user_profile: Bot designers can create a global variable like "user_profile" to store user-specific information such as name, preferences, or user-specific settings. This variable can be updated as the bot gathers more information about the user during the conversation.
  2. Local Variables - Local Variables are user-defined variables that are scoped to a specific journey within the bot. Unlike global variables, they cannot be accessed or modified outside of their respective journeys. Local Variables provide a way to store and manage data that is relevant only to a particular conversation flow. Designers can set default values for local variables, and their values can be updated as the bot progresses through the journey.

Variable Data Types

There are three data types available for variables:

  1. Number
  2. String
  3. JSON

How to use a variable

Below are the steps to use variables in the chatbot journey building:

  1. Open the Variable Management screen. (you can open the Variable Management screen by clicking on Manage Variables on the Journey Builder Canvas)
  2. Give a name to the variable, eg - user_phone, user_email
  3. Select the data type from the dropdown on the manage variable screen.
  4. Provide a default value(optional) and click save.

Limitations

  1. Any special character can’t be added to the variable name except \, _, -
  2. Duplicate name variables can’t be added.
  3. System Variable and Global/Local 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