Hi, Humans. How may we help you?

02. Automations API: How to use and integrate with Zapier in Zenvia Customer Cloud
6 min
Created by Leonora Alves on 2/15/2024 3:59 PM
Updated by Leonora Alves on 3/8/2024 3:46 PM

Zenvia Customer Cloud allows you to initiate an automation through an API call on a third-party server or system.

⚠️ Attention: This feature is available only for users with the Operator or Admin profiles.

In this article, we explain why to use Zenvia Customer Cloud's marketing automation API and how it works in practice.

Integrating an API requires advanced technical knowledge, so it's important to seek the assistance of a developer. Information about the marketing automation API can be found in the Zenvia APIs.

Why use the automation API

Imagine you have a registration page for an online event on marketing strategies. Instead of immediately providing the access link to the event once someone fills out the registration form, you can send communication to the interested person with all the necessary information, including a unique link to access the event.

In this case, the API can connect the information collected through your registration form to trigger a marketing automation campaign.

In summary, you initiate a communication flow through an API call on a third-party server or system.

How the API integration works

Before integrating the API, it's necessary to create the automation that will receive the external stimulus. Let's use the example of the registration form for the online event.

To do this, in the side menu, go to Message broadcast > Broadcast and automation and click on Create automation. Then, select the API trigger, which is the rule that defines the activation of the flow.

With the automation active in Zenvia Customer Cloud, it's necessary to integrate the trigger that starts the communication flow - the API - with your system. To perform this integration, we use Zapier, an integrator created to facilitate communication between software.

Creating an integration with Zapier

You already know that Zapier is the integration facilitator, responsible for connecting one application to another for the exchange of information. To do this:

  1. Log in to Zapier and select the orange +Create Zap button in the left sidebar;
  2. Choose the trigger application;
  3. Select the trigger, which is the event that occurs in the application that triggers the Zapier data flow. Triggers are displayed according to the possibilities offered by the selected application. In this case, the available events are:
    • New Form Response: the event that triggers the Zapier flow is when a new form response is received;
    • New or Updated Form Response: the event that triggers the Zapier flow when a new form response is added or modified.
  4. Click Continue;
  5. Select the account you want to connect to the application.

Done. The next step is to add an action for the trigger, i.e., the automation API data for the flow to start when the form is answered.

Configuring the action

  1. Select the application for Zapier to record an action when the configured trigger is triggered. To do this, search and choose the application you want to connect to the form;
  2. Choose the event that Zapier will perform in the selected application when triggered. In this case, we use the Webhooks by Zapier application as an example;
  3. Define the data you want to send to your action application. At this stage, it's necessary to match the data from your Zenvia Customer Cloud automation with the Zapier flow. To do this, in the created automation, click on the trigger to check the request code.
  4. After matching all fields in Zapier, click Continue;
  5. The summary of the request is displayed, and you can test your action to see if it's working as expected by clicking on Test Action. After testing, simply publish the action by clicking Publish Zap.

See an example of field association:

Field in Zapier

API Request

Method

It is the method of the action in the URL. In case, it is the POST method.

URL

It is the URL of the automation API, i.e., https://api.zenvia.com/v2marketing-automations/{ID-of-the-campaign}/dispatches 

Headers

These are the parameters provided in the request header. To use the API, it's necessary to include:

  • X-API-Token: it's the authorization token, which you can find in the Tokens and Webhooks panel in the Settings section of the Zenvia Customer Cloud.

  • Content-Type: it's the response content type, which is application/json

Data

It's the body of the API. For example:

{

"recipientChannels":{"sms":"{CONTACT NUMBER}"},

"variables": {"name":"string"}

}


Done! By following these steps, you can now send data from your system or provider to a Zenvia Customer Cloud marketing automation.