Zenvia Customer Cloud Flow Chatbot and How to Use Variables
5 min
Created by Maria Malheiro on 12/10/2025 4:36 PM
Updated by Maria Malheiro on 12/11/2025 11:01 AM

Learn more about how to perform validation and direct the user to different paths, as well as how to use variables in the Flow Chatbot of Zenvia Customer Cloud.

Context

The Zenvia Customer Cloud flow chatbot does not have a native “time validator.” However, you can build this logic using variables and conditions inside the builder to check the current time or compare it with a time provided by the user.

To validate time, there are two approaches:

  1. Based on the current system time (via an external API that returns date and time)

  2. Based on the time provided by the contact (using the user’s response in the flow)


Building the flow

Step 1 – Capturing the time

You will need to store the time you want to validate using variables:

If the user provides the time:

  • Use an Open field block requesting: Enter your time in the HH:MM format.

  • Define a variable for this field, for example: <?$horarioInformado?>.

If using the current time:

  • Use an API Call to request the time from a server/time service in hours/minutes format.

  • Save this return value in a variable, for example: <?$horaAtual?>.


Step 2 – Creating the validation logic

After capturing the value, use a Destination in the builder to compare it.

  1. In the validation block, go to Destinations.

  2. Create a rule:

  • Attribute: <?$horarioInformado?>

  • Operator: Greater than or equal to / Less than or equal to

  • Value: desired interval (e.g., 08:00 and 18:00, or numeric values like 8 and 18 if using only hours).

Define Go to:

  • Normal service block (if within operating hours)

  • Warning block (if outside operating hours)


Step 3 – Using variables correctly

Basic variables:

  • <?$name?> → Contact name

  • <?$phone?> → Phone number

  • <?$email?> → Email

  • <?$visitor.firstName?>, <?$visitor.lastName?> → Name from the channel’s social account

Custom variables:

  • Created in the flow or via upload/API in the contact database

  • Used as: <?$minhaVariavel?>

  • Where minhaVariavel is the name defined during creation

Important:
Variables can be used both to display values in the conversation (e.g., “Hello, <?$name?>!”) and for validation in Destinations.

If a variable comes from an Open field block, it only receives a value after that block executes.

In API calls, variables can store returned data (e.g., <?$resposta_api.body.horario?>).


Practical example – Business hours validation

Assume your business hours are 08:00 to 18:00.

Flow:

  1. Welcome Block:
    “Hello, <?$name?>! Before continuing, I need to check whether we are within our business hours.”

  2. Time Capture Block:
    API Call to fetch the current server time (or an Open field for user input) → variable <?$horaAtual?>.

  3. Validation Block:
    Destinations:

    • If <?$horaAtual?> Greater than or equal to 8 AND Less than or equal to 18Available service block

    • Otherwise → Out of hours – automatic message block

  4. Available service block:
    “We are within business hours, I will transfer you to a human agent.”

  5. Out of hours block:
    “We are currently outside business hours. Our service hours are from 08:00 to 18:00. Please return within this period.”


Checklist for proper functionality

  • Create the variable that will store the time

  • Decide whether it will come from the user or an API

  • Use Destinations to compare values

  • Test the flow using the Test chatbot button

  • Publish the bot so the rules go into production

For more information on how to create and configure variables in a chatbot, check the documentation.