In Zenvia Customer Cloud, the API Call feature allows you to integrate external systems into your chatbot. With it, you can:
Retrieve customer data from a CRM
Send information to external systems
Automate actions based on dynamic data
An API (Application Programming Interface) is the way different systems communicate with each other.
How to access
In the bot builder:
Click the three dots on the block (or anywhere on it)
Click Add content
Select API Call
How to configure the API Call
Fill in the following fields:
Method: GET, POST, PUT, DELETE, or PATCH
URL: API endpoint
Headers: (e.g., Authorization, Content-Type)
Body: according to the expected format (e.g., JSON)
Why use another block?
Block execution follows this order:
Sends the message
Receives messages
Saves variables
Executes actions (including API)
Defines the next flow
This means the API response is only available after the block finishes execution.
Conclusion:
You need a new block to use the returned data.
Practical example
API response
Imagine your API returns:
{ "body": { "cliente": { "nome": "Carlos Silva", "plano": "Premium" } } }
Goal
Display the customer’s name in the conversation.
How to access the variable
Default API variable:
<? $resposta_api.body ?>
To access a specific field:
<? $resposta_api.body.cliente.nome ?>
Correct flow example
Block 1 — API Call
Configure the API
Does not display data yet
Block 2 — Display response
Message:
Hello, <? $resposta_api.body.cliente.nome ?>! Your current plan is <? $resposta_api.body.cliente.plano ?>.
Flow visualization
[Block: API Call] ↓ [Block: Display data] "Hello, Carlos! Your plan is Premium."
Array example
If the API returns:
{ "body": { "events": [ { "channel": "widget", "eventName": "new_dialog" } ] } }
To access the first event channel:
<? $resposta_api.body.events[0].channel ?>
Message:
Your service started through the <? $resposta_api.body.events[0].channel ?> channel.
Best practices
Always validate the JSON structure first
Use clear field names in the API
Test the API response before using it in the flow
Clearly separate:
API block
display block
Important note
The variable:
<? $resposta_api.body ?>
Remains available until a new API call is made
Is always overwritten by the most recent response