Creating Local Variables

Creating Local Variables

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.
Idea
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 local variables and why use them?

To store predefined values, you can create a local variable and assign them wherever necessary in the flow. These variables are accessible anywhere within the same flow, but are not available outside of it.
For example, if you have a local variable named Coupon in a flow called Bookings, you can use this variable in any block within the Bookings flow. However, the Coupon variable cannot be accessed in a different flow called Grievances.
InfoThese variables are useful when you need to work with a predefined value rather than relying on user input as you would with Block variables.

How to create local variables 

1. Select the Flow in which you want to add the local variable.
2. Select the @ icon on the left side. The Add Variable dialog box will open.
3. In the dialog box, select the Variable Type as Local Variable.
4. Select Add Local Variable.

5. Provide the Variable Name, Data Type, and Variable Value.
6. Click Save.
Info
Choosing the data type enables the entered local variable is validated as the selected type, ensuring they are correctly formatted.

Notes
Points to be noted when creating a local variable:
1. The following data types are available in GC-
  1. String
  2. Number
  3. Image
  4. Audio
  5. Video
  6. Object
  7. Date
  8. Date and Time
  9. File
2. The maximum size of Image, Audio, Video, and File that can be added as a local variable is 14 MB. If the channel set is                WhatsApp, then this limit would be 10 MB.

Using created local variable in the flow

1. Create a block, then click the @ icon.

2. Select the local variable to be displayed.

Output in GC:

How can you use local variables in your flow

  1. Consistency: Local variables allow you to store and reuse predefined values consistently across different blocks within the same flow. This ensures that the chatbot can use these values accurately throughout the conversation.
  2. Efficiency: By using local variables, you can avoid redundant data entry and streamline the flow. Instead of repeatedly inputting the same values or configuring them multiple times, you can assign them once and use them as needed.
  3. Customization: Local variables enable the chatbot to handle specific scenarios and conditions within the flow. For example, if you have a predefined discount rate or a special offer, you can store it in a local variable and apply it wherever required in the flow.
  4. Modularity: They help maintain modularity in the flow design. Each flow can manage its own set of local variables, ensuring that the values are used appropriately within that flow and do not interfere with other flows.
  5. Simplified Management: By isolating predefined values within local variables, you can simplify the management of the chatbot’s logic and make updates or adjustments more easily without affecting other parts of the system.
Notes
  1. If the block variable is being edited, it will automatically be reflected in wherever it has been used.
  2. The block variables can be re-used used multiple times according to the requirement.

Variable validations  

String Variable  

Field

Mandatory

Character limit

Additional details

Variable name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed

Variable value

Yes

Max 100

HTML tags not allowed

Description

No

Max 100

Characters <, >, “, ’ not allowed


Number Variable  

Field

Mandatory

Character limit

Additional details

Variable name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed

Variable value

Yes

Max 100

Must contain a valid number


Media Variable  

Field

Mandatory

Character limit

Additional details

Variable name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed

Variable value

Yes

Max size 14 MB

Accepts supported media files


Object Variable  

Field

Mandatory

Character limit

Additional details

Variable name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed

Variable value

Yes

Must contain valid nested key value pairs

 

Name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed

Value

Yes

Max 100 for string or number; Max 14 MB for media

HTML tags not allowed for string values


Date Variable  

Field

Mandatory

Character limit

Additional details

Variable name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed


Date Time Variable  

Field

Mandatory

Character limit

Additional details

Variable name

Yes

Max 250

Cannot start with a number; Only letters, numbers, and underscore allowed