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.
For example, collect the customer’s name, email address, and phone number, then have the bot automatically use these details in future interactions by storing them as variables.
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 block variables and why use them?
The information received in a block during a conversation is stored in block variables. They allow you to utilize the stored data at various points within the flow, enabling its reuse as often as needed. This flexibility ensures that the data can be consistently applied throughout the block’s operations.
Additionally, it helps in maintaining the modularity and organization of the flow, as each block can manage its own set of variables without affecting others.
How to create block variables
You can create block variables through the responses received from the end-user.
For example, the user's name collected from the question block is stored as a block variable, which can then be used in the following block to display their name.
1. Creating a question card.
Question blocks include an option that allows you to rename block variables. By default, the block name you provide is used as the variable's name. For example, if you name the block Name, the default variable name will be Name_. However, you can edit and customize the variable name if needed.
2. Selecting the required block variable.
3. Creating the next block where the entered name has to be displayed.
Output in GC:
How can you use block variables in your flow:
- Personalized greetings: A block variable can store the user's name received in an earlier block, allowing the bot to greet the user by name in subsequent messages within the same flow.
- Order details: In an ecommerce chatbot, block variables can store order details, such as the product name, quantity, or price collected from the user, which can then be referenced to confirm the order in the same flow.
- Survey responses: During a survey, each response collected from the user can be stored as a block variable. These responses can be used to provide personalized feedback or results at the end of the survey.
- Conditional logic: Block variables can be used to store user preferences or selections, which can then be used to guide the conversation. For instance, if a user selects a particular service, the next steps in the conversation can be tailored accordingly.
- Appointment scheduling confirmation: In a chatbot designed to schedule appointments, block variables can store the chosen date and time, which can then be displayed for confirmation before finalizing the booking.