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:
Based on the current system time (via an external API that returns date and time)
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.
In the validation block, go to Destinations.
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:
Welcome Block:
“Hello, <?$name?>! Before continuing, I need to check whether we are within our business hours.”Time Capture Block:
API Call to fetch the current server time (or an Open field for user input) → variable<?$horaAtual?>.Validation Block:
Destinations:If
<?$horaAtual?>Greater than or equal to 8 AND Less than or equal to 18 → Available service blockOtherwise → Out of hours – automatic message block
Available service block:
“We are within business hours, I will transfer you to a human agent.”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.