Issue with ActiveCampaign and Twilio workflow

This topic was automatically generated from Slack. You can find the original thread here.

Joseph : Hello Pipedream team! I’m excited to join and hopefully find a way to resolve my question. I am a noob so please bear with me : ) I am trying to connect ActiveCampaign email marketing account with Twilio account in such a way that when a new Contact is added to ActiveCampaign an outbound call to contact’s phone number is automatically made by Twilio.

I was able to connect the ActiveCampaign and Twilio app in my workflow in the following way:

Step #1New Contact Added to Liststeps.trigger for ActiveCampaign followed by Step #2 steps.post_account_calls for Twilio.

However, when I pass test new added Contact data from ActiveCampaign to Twilio in my flow I get the following error message for Twilio: ErrorRequest failed with status code 400
Error - 21201 No ‘To’ number specified
You attempted to initiate an outbound phone call, but you did not specify what number to call in the ‘To’ POST parameter

The error code shown for it is:

{
“code”: 21201,
“message”: “No ‘To’ number is specified”,
“more_info”: “[params.To[“contact[phone]”]](Error 21201 | Twilio>”,
“status”: 400
}
at null.createError (/opt/ee/node_modules/axios/lib/core/createError.js:16:15)
at null.settle (/opt/ee/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/opt/ee/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:203:15)
at null.endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

I think the issue is that params is not properly set up in the code at ActiveCampaign first step in the workflow. Here is the full code for this first step:

const activecampaign = require("…/…/activecampaign.app.js");
const common = require("…/common-webhook.js");

module.exports = {
…common,
name: “New Contact Added to List”,
key: “activecampaign-contact-added-to-list”,
description: “Emits an event each time a new contact is added to a list.”,
version: “0.0.1”,
methods: {
…common.methods,
getEvents() {
return [“subscribe”];
},
async getMeta(body) {
const { list } = await this.activecampaign.getList(body.list);
const { date_time: dateTimeIso } = body;
const ts = Date.parse(dateTimeIso);
return {
id: ${body["contact[id]"]}${list.id},
summary: ${body["contact[email]"]} added to ${list.name},
ts
};
console.log(<http://params.To[%22contact[phone]%22]));
},
},
};

I know that the params is completely wrong here, put in the wrong place, etc.

I would greatly appreciate any tips and help in getting this fixed so that outbound calls can be placed automatically to Contacts added to ActiveCampaign list. Thank you!

Dylan Sather (Pipedream) : Hi , would you mind clicking the Share button near the top-right of your workflow and share it with dylan@pipedream.com? I can take a look at your workflow config to see if the issue is there. That’ll also let me see if the issue might be in the event emitted by the trigger.

Joseph : Hi , thank you for your quick reply! I’ve sent you an invite to join my workflow as collaborator and would appreciate any guidance with the issue I have with it. Thanks!

Dylan Sather (Pipedream) : I apologize, I didn’t receive an email invite. Could you try inviting the user dylburger (that’s my username, which also works for invites)

Joseph : I’ve sent an invite to dylburger (my worklfow is set to private if that makes any difference). Thanks!

Dylan Sather (Pipedream) : Thanks. That action should have a parameter that lets you specify the phone number and other relevant data, but for some reason it’s missing. I’m going to publish a new version of this action, I’ll just need to test it on my end. I’ll get back to you ASAP.

Dylan Sather (Pipedream) : I published two actions that should help: a new action that should allow you to make phone calls correctly, and an action that helps convert phone numbers into the format Twilio expects (E.164). This last action essentially takes numbers like “415 123 4567” and converts them into “+14151234567

Dylan Sather (Pipedream) : Try removing the current phone call action from your workflow, then add the E.164 conversion step. You can pass the phone number that arrives with your event in the “Number” param of that action by using the object explorer.

That step will return an E.164 phone number, which you can pass to Twilio. That action accepts a To / From number, and any text you’d like to speak when the person picks up the phone.

Let me know if that helps

Joseph : Thank you very much ! I added the new E164 conversion step followed by the new Twilio Make A Phone Call step and it seems that it worked (I will need to do more testing with different numbers tomorrow)!

I honestly did not expect to get such professional help so fast - really appreciate it! I will move more of my projects to Pipedream,

One additional quick question - please let me know if in the first step of my Workflow, New Contact Added To List, I can specify only one particular list in ActiveCampaign that would trigger this flow. In other words, I would like to make automated calls through Twilio only to Contacts that were added to a specific List in Active Campaign and not to those added to any other Lists.

If it is possible - please let me the best way to do it. Thanks!

Dylan Sather (Pipedream) : I believe we should be able to find a way to make this work. I opened a feature request to track this here if you’d like to follow that.

In the meantime, the list ID is present in the incoming event from ActiveCampaign, so you could add a step at the top of the workflow so that it only runs on the lists you care about:

if (![1, 2, 3].includes(steps.trigger.event.list)) {
  $end(`List ${steps.trigger.event.list} not in the list we care about. Exiting`)
}

Just replace [1, 2, 3] with the list IDs you’d like to watch. If the incoming list ID isn’t in that array of list IDs, we’ll call $end(), which ends the execution of the workflow early.

Joseph : Thank you! I tried this by inserting the code you specified into Run Node.js steps.activecampaign and put it as a second step in my workflow, between New Contact Added to List step and my Twilio step.

However, even after I specified the list number inside your code that I would like to allow and ran a test using a Contact from that allowed list, I received “List 23 not in the list we care about. Exiting” even though List 23 was specified by me as an allowed list.

Could you please advise what I am doing wrong here?

Dylan Sather (Pipedream) : In this case, it looks like ActiveCampaign sends the data as a string, not a number. Try this, instead:

if (!["23"].includes(steps.trigger.event.list)) {

Joseph : Thank you - looks like I need a paid plan to implement this code, I will upgrade shortly.

Dylan Sather (Pipedream) : did you encounter a specific error, or hit your daily quota? Let me know if you’re seeing a specific issue I can help you troubleshoot

Joseph : Hi Dylan - when I run a test after steps.
activecampaign was added as a second step between “New Contact Added To List” step and my Twillio step I get the following 403 error: “message”: “Upgrade your account to enable the Accounts Feature”

I thought this means that I need to upgrade from a free to a paid Pipedream plan to be able to use this step this way.

My code for steps.activecampaign is:

if (![“23”].includes(steps.trigger.event.list)) {
$end(List ${steps.trigger.event.list} not in the list we care about. Exiting)
}
return await require("@pipedreamhq/platform").axios(this, {
url: ${auths.activecampaign.base_url}/api/3/accounts,
headers: {
“Api-Token”: ${auths.activecampaign.api_key},

List ID 23 is the only List in ActiveCampaign to which when a new contact is added I want my workflow to run and progress to Twillio step.

Thanks!

Dylan Sather (Pipedream) : That upgrade message is actually returned from the ActiveCampaign API, not Pipedream

Joseph : I see - other than the ActiveCampaign upgrade, is the code I sent you for steps.activecamapign step correct to run the workflow only for contacts added to a specified list ID?

Dylan Sather (Pipedream) : Yes, that conditional statement / $end code should work as intended now

Joseph : Got it, thank you!