What are variables?
Variables are placeholders that store user input, data from external systems, or other important information that needs to be saved and reused later in the bot conversation.
They help maintain the context of the conversation, allowing the chatbot to retrieve data and respond appropriately based on previous interactions.
These are categorized based on their scope, which determines where the variable is to be used. Variables are only accessible within their defined scope. There are four types used here: block variables, local variables, global variables, and session variables.
By using variables, you can personalize and tailor conversations within your GC chatbot, allowing for flexible and customized interactions.
Why use variables?
Helps maintain the context of the conversation, allowing the bot to refer to previous user inputs and respond accurately.
Allows the bot to retrieve and use data dynamically, making conversations more flexible and responsive to user needs.
Retrieves crucial information, such as user preferences or data from external systems, which can be used later in the conversation or across multiple interactions.
Variables help streamline conversation flows by reducing redundancy and ensuring that relevant data is easily accessible when needed.
By categorizing variables based on their scope (block variables, local variables, global variables, and session variables), they ensure that data is used appropriately within the intended parts of the conversation.
What are session variables?
Session variables are dynamically retrieved during the conversation and are accessible across all flows within an organization.
For example, session variables can identify whether a customer is logged in, a paid subscriber, or a prospect, and guide them through the appropriate path within a flow.
Why use session variables?
They help tailor the conversation to the user’s specific needs, like showing content based on their location or account status.
They allow the chatbot to show real-time, relevant information based on data gathered during the session, making the chat more interactive.
They enable the chatbot to take specific actions or follow different paths based on user conditions, like whether the user is logged in or what options they’ve chosen.
With default values, session variables ensure the chatbot conversation has no missing context.
Session variables are available in all flows, but their values are dynamic and can differ session by session.
Creating a session variable
1. Navigate to Setup > Self Service > Guided Conversations > Session Variable.
2. Click Create Session Variable.
3. Enter the Variable Name.
4. Choose Variable Type.
Choosing the data type enables the entered session variable is validated as the selected type, ensuring they are correctly formatted.
The following are the available data types:
- String
- Number
5. Enter Default Value.
When creating a session variable, it’s essential to provide a default value, which will be used if the system is unable to identify the actual value. For example, if the system cannot determine the Customer’s Region, it will show the value provided for the Region variable.
6. Click Add.
Once a session variable is incorporated into a flow, you can review the path followed by each session variable under the preview mode. You also can edit the variable values during the preview.
Using the created session variable in a GC flow
1. Create a block; click on the @ icon.
2. Select the session variable to be displayed.
3. Click Preview.
4. Choose Session Variable Preview.
You can change the default value for the session variable here or continue by clicking Save & Preview.
Output in GC:
For preview purposes, the default value will be shown. During a live session, the data will be dynamically retrieved and presented to the end-user.
How can you use session variables in your flow:
- Collecting items in a virtual shopping cart for the user to place an order.
- Storing raw data from an API call for subsequent processing during the conversation.
- Maintaining chat history for the current interaction to reference previous messages.
- Saving an order number, policy number, or tracking number for easy retrieval within the session.
If the session variable default value is being edited, it will be reflected in wherever it has been used automatically.
The session variables can be re-used used multiple times according to the requirement.
Session variables can be utilized in any conversation flow within your organization, but the value fetched will be dynamic to that particular conversation.