Table of Contents

Create a contact and assign it to a list in Activecampaign (API)

Pau Sanchez Updated by Pau Sanchez

Here is how you can create contacts in ActiveCampaign via API, and assign it to a specific list.

Add Contact to ActiveCampaign

Below is the sample flow that we are going to build:

  1. Go to the Settings section

  1. Select Developer

  1. Here you will need to copy for later 2 things, the url and the Key

  1. Now, we go back to Landbot, and create a Webhook block

  1. First we need to set the URL.

We need first the URL from the developers section:

  1. We will use the Create Contact method of Activecampaign API: https://developers.activecampaign.com/reference#create-a-contact-new

  1. Change the url part of "youraccountname" according to the URL from the developer section

https://landbot47109.api-us1.com/api/3/contacts

  1. Paste it in the Webhook URL:

  1. Now in the Header Section we will add the "Api-Token" key, and below we will paste Key from the developer section:

  1. Active the Body section and add the sample body of the documentation:

Here is the code:

{
"contact": {
"email": "johndoe@example.com",
"firstName": "John",
"lastName": "Doe",
"phone": "7223224241"
}
}

  1. Press TEST and check the response, with this you will upload this sample data:

  1. Now that we know that the setup is correct, we will change the use Landbot variables in the body:

{
"contact": {
"email": "@email",
"firstName": "@name",
"phone": "@phone"
}
}

Here we are using the Landbot variables, @email, @name and @phone

  1. Now we need to set the Webhook Variables for the testing, right below the body section:

  1. Press test again to make sure the variables are set correctly:

And now is added to the Main first list.

Add Contact to ActiveCampaign List
  1. 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 as Variables section of the bot:

  1. Here we will select "contact.id" and will create a Landbot variable to store the value ( we will use @active_id (type String)

  1. Now we need to add another Webhook, that will trigger the Activecampaign to change the contact we just added to the desired list

  1. Here the in URL we will use this one:
    https://landbot47109.api-us1.com/api/3/contactLists

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:

  1. Now in the body section:
{
"contactList": {
"list": 2,
"contact": "@active_id",
"status": 1
}
}

  1. 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:

  1. 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:

{
"contactList": {
"list": 2,
"contact": "@active_id",
"status": 1
}
}

  1. Save the Webhook and the bot. And that's it

It might take few seconds, to a contact to be uploaded, please make sure to Refresh the browser to see the changes applied, as they won't be displayed in real time

Add Tag to Contact created in ActiveCampaign

Now that we have the contact created and in a specific list, we will add a tag to that contact. This is the link to the API Docs: https://developers.activecampaign.com/reference#create-contact-tag

  1. Here we will duplicate the Webhook we used earlier to add the contact to a specific list:

So we will work based on that duplicated block:

  1. First we need to change the url:
    https://youraccountname.api-us1.com/api/3/contactTags

  1. Now we will change the Body section:

{"contactTag": {"contact": "@active_id","tag": "1"}}

1 is the id of the Tag, by default is the order of the tags in your system. Do no use the name of the tag

How did we do?

Contact