Hi, Humans. How may we help you?

03. How to manage a Variable
6 min
Created by Maria Malheiro on 2/6/2024 8:51 AM
Updated by Ligia Sarmento on 7/25/2024 5:35 PM

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:

  1. Click on Settings in the bottom menu of the Constructor on the right.

  2. Go to the Variables tab.

  3. Click on Create extra variable.

  4. Give a Name that describes the expected value for the attribute.

  5. Enter the Identifier.

  6. 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:

  1. Click on Add block.

  2. Select Add content and choose Data output > Text message.

  3. 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:

  1. Click on Add block.

  2. Choose Data input > Open field.

  3. 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.

  1. Click on Add block.

  2. Choose Data output > Send file.

  3. Choose PDF as the File type.

  4. Enter the file URL.

  5. Choose the download button title, such as "Second copy of the invoice."

  6. Click outside the block to save.

  7. 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?>.

  1. In the Step 3 block, click on Add content > Text message.

  2. 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.