Create a contact and assign it to a list in Activecampaign (API)
Here is how you can create contacts in ActiveCampaign via API, and assign it to a specific list.
Below is the sample flow that we are going to build:
- Go to the Settings section
- Select Developer
- Here you will need to copy for later 2 things, the url and the Key
- Now, we go back to Landbot, and create a Webhook block
- First we need to set the URL.
We need first the URL from the developers section:
- We will use the Create Contact method of Activecampaign API: https://developers.activecampaign.com/reference#create-contact
- Change the url part of "youraccountname" according to the URL from the developer section
- Paste it in the Webhook URL:
- Now in the Header Section we will add the "Api-Token" key, and below we will paste Key from the developer section:
- Active the Body section and add the sample body of the documentation:
Here is the code:
- Press TEST and check the response, with this you will upload this sample data:
- Now that we know that the setup is correct, we will change the use Landbot variables in the body:
Here we are using the Landbot variables, @email, @name and @phone
- Now we need to set the Webhook Variables for the testing, right below the body section:
- Press test again to make sure the variables are set correctly:
And now is added to the Main first list.
- We need now to get the id given by Activecampaign, so we can after move them to a specific list. To do that, once you have the test, go to the Save Response section of the bot, and click on "Select data from the response:
- Here we will select "contact.id" and will create a Landbot variable to store the value ( we will use @active_id (type String)
- Now we need to add another Webhook, that will trigger the Activecampaign to change the contact we just added to the desired list
- Here the in URL we will use this one:
Changing the "landbot47109" for your account name
Also, using the same taken as in the first Webhook block.
Here is how is displayed in their documentation:
- Now in the body section:
- The list value (in the example above is 2) and the status (in the example above is 1) you will find it easily in the URL of your list in ActiveCampaign, go to the List section of Activecampaign:
- Once you are in List section select the desired List, and check the url:
As you can see here the list value is 2 and the status is 1. The same values used in the body:
- Save the Webhook and the bot. And that's it