In Zenvia Customer Cloud, the API Call feature allows users to include an API within their chatbot. An Application Programming Interface (API) is a way for one program to interact with another, hence API calls are the means by which they interact. Thus, it's possible to use an API call to send data to your CRM, query customer data in databases, or even send external communications.
How to Access
The API Call content is available in the Constructor and to access it, simply click on the three dots of the block or anywhere within it.
This will open the Block Details modal, then follow these instructions:
- Click on Add content > Conversation actions > API Call.
- In Method, specify the type of your API, whether it's: POST, GET, DELETE, PUT, or PATCH.
- Provide the URL, including a link to this API.
- In Header, include the respective code, editing the code will be similar to any common editor. For example, it could be Authorization, Application, etc.
- In Body, include the code. Remember that this will depend on the API. For example, if we have a JSON application, in the body, the code will be JSON.
💡 Tip: If the API response includes an array of objects, as in the example below, where you want to access the communication channel of the first event, the code to display this information would be:
"resposta_api": {
"body": {
"events": [
{
"extra1": null,
"extra2": null,
"channel": "widget",
"eventName": "new_dialog",
"assistantId": 142,
"environment": "dev"
}
]
},
"code": 200,
}
In this example, events[0]
refers to the first object within the events
array, and channel
is the field you want to access and display in the chatbot conversation.