Hi, Humans. How may we help you?

How to create and configure variables in a chatbot
4 min
Created by Maria Malheiro on 2/6/2024 8:51 AM
Updated by Maria Malheiro on 2/26/2026 12:29 PM
Important: Before following the instructions, make sure the feature is available for your access profile.

Variables allow you to store and reuse information throughout the chatbot conversation flow. With them, you can personalize messages, save user responses, control steps, and much more. There are two types of variables: Contact and Context. See each one below.

Contact Variables

Contact variables store information during a conversation and are divided into basic, which are fixed and pre-existing, and additional, which can be created for data specific to the context or contact identification. Both types can have their values displayed in messages and conditions within blocks through the Identifier attribute. The values filled in during conversations will be available in the conversation details. See below:

1. Basic Variables

These are common pieces of information that most chatbots usually ask for, such as name or email. Each of these variables has a specific code to be used in messages.

See below examples of variables and their codes:

  • ZIP Code: <?$cep?>
  • CPF (Tax ID): <?$cpf?>
  • Name: <?$name?>
  • Email: <?$email?>
  • Gender: <?$gender?>
  • Phone: <?$phone?>
  • Date of Birth: <?$birth_date?>

Whenever you need to use one of these variables in a message, simply insert the corresponding code, such as <?$name?> for the user’s name.

2. Additional Variables

Additional variables are customizable and can be created according to the chatbot’s needs. For example, if you want to capture specific information, such as a user preference, you can create a new variable.

How to create an additional variable

  • Go to Settings in the lower menu of your chatbot Builder.
  • Click the Variables tab.
  • Choose the option Create additional variable.
  • Give it a name that clearly explains what this variable will store.
  • Define the Identifier (variable code).
  • Finally, click Save.

Context Variables

Context Variables are used to control the conversation flow and store temporary system information, without impacting the contact’s data.

Main characteristics

  • They do not populate the customer’s contact record.

  • They are available only within the conversation context.

  • They can be viewed in the context block, within the conversation details area.

How to create a Context Variable

When selecting the Context Variable option, fill in the following fields:

1. Identifier

Enter the variable identifier.

⚠️ Important rules:

Allowed:

  • Letters

  • Numbers

  • _ (underscore)

Not allowed:

  • Spaces

  • Special characters

Default value
The field comes pre-filled by default with the syntax used in the context variable process:

<? #name ?>

2. Value type

Select one of the options:

  • User input
  • Other value

This setting determines how the variable value will be filled during the flow execution.


Importante: Always remember to publish your chatbot after completing the configurations so that it becomes active and accessible to users. Without publishing, it will not be available for interaction. If you follow the instructions in this article and still experience difficulties or have questions related to Zenvia Customer Cloud, please contact our Support team directly. Check the step-by-step guide in the article: How to contact Zenvia technical support.