In the context of chatbots, variables are elements that store temporary information during interactions with users. This information can include responses provided by users, such as Name, CPF, and Email.
Variables allow the chatbot to personalize conversations, make data-based decisions, and provide a more dynamic and efficient experience.
Existing Variables
All variables have their respective identifier codes, which are used to insert the variable values into the chatbot's messages. For example, the variable Name has the identifier code <?$name?>
.
Whenever you need to use a variable within your conversational flow, you will need to include the corresponding variable code in your message.
Variables can be of the following types:
Basic Variables
These are common data collected from all users, such as Name and Email. These variables are standardized and generally used to identify or contact users.
Below are all the variables and their respective identifier codes:
-
ZIP Code:
<?$cep?>
-
CPF:
<?$cpf?>
-
Name:
<?$name?>
-
Email:
<?$email?>
-
Gender:
<?$gender?>
-
Phone:
<?$phone?>
-
Birth Date:
<?$birth_date?>
Extra Variables
These are custom fields that can vary as needed. You can create these variables to capture specific information, such as user preferences or responses to custom questions. The definition and purpose of these extra variables are determined by you, according to your chatbot's specific requirements.
Below is how to create an extra variable:
-
Click on Settings in the bottom menu of the Constructor on the right.
-
Go to the Variables tab.
-
Click on Create extra variable.
-
Give a Name that describes the expected value for the attribute.
-
Enter the Identifier.
-
Click on Save attribute.
Practical Tutorial
Now let's understand how to manage and use variables in your chatbot's conversational flow.
We will cover the creation of a complete flow, from collecting user data to sending personalized responses.
💡 Tip: To follow the tutorial, have your chatbot Constructor open.
Step 1: Configuring Text Messages
Let's start with a personalized greeting. Follow these steps to add a text message to your flow:
-
Click on Add block.
-
Select Add content and choose Data output > Text message.
-
Write a greeting message, such as "Hello! How can I help you today? Please provide your name and your question," and finish by clicking on Close edit.
Step 2: Collecting User Information
Now, let's add an input field to collect the user's name and question:
-
Click on Add block.
-
Choose Data input > Open field.
-
Return to the block created in Step 1, click on Destination > Default destination , and choose the second block as the destination.
Step 3: Sending Multimedia File
Let's suppose that after providing their name, the user informs that they need help with the second copy of their invoice.
Let's follow the conversation flow and configure the chatbot to send the file.
-
Click on Add block.
-
Choose Data output > Send file.
-
Choose PDF as the File type.
-
Enter the file URL.
-
Choose the download button title, such as "Second copy of the invoice."
-
Click outside the block to save.
-
Return to the block created in Step 2 and set this Step 3 block as the Default destination.
Step 4: Personalizing Responses with Variables
- In Step 2, you collected the user's name.
- In Step 3, you configured the file sending.
Now, let's configure a text message where the bot uses the collected variable <?$name?>
.
-
In the Step 3 block, click on Add content > Text message.
-
Configure the message with the variable code <?$name?> to personalize the response: “Here is your invoice,
<?$name?>
.”
This way, the chatbot will replace <?$name?>
with the previously collected user name, making the interaction more personalized and efficient.
After completing, see in practice how the conversational flow works with this configuration. Click on Save changes and then Test Chatbot in the bottom left bar of the Constructor.