I have a Zap app that starts by leveraging a Mailchimp open trigger. Once a user opens an email in Mailchimp, I want to add a tag to the prospect’s record in my CRM app. The way I am going about this after the Mailchimp trigger is two action steps (would love only one but don’t know how to do it otherwise):
- Find a Prospect via Email
- Add a Tag to Prospect
I have been successful in retrieving the prospect’s data with Find a Prospect via Email. It finds the prospect from the Mailchimp email address and returns that data, as follows (subset of full dataset):
{
"data":
{
"type": "prospect",
"id": 1436,
"attributes": {
"addedAt": null,
"addressCity": null,
"addressCountry": null,
"addressState": null,
"addressStreet": null,
"addressStreet2": null,
"addressZip": null,
"angelListUrl": null,
"availableAt": null,
"callOptedOut": false,
"callsOptStatus": null,
"callsOptedAt": null,
"campaignName": null,
"clickCount": 0,
"company": null,
"companyFollowers": null,
"companyFoundedAt": null,
"companyIndustry": null,
"companyLinkedIn": null,
"companyLinkedInEmployees": null,
"companyLocality": null,
"companyNatural": null,
"companySize": null,
"companyType": null,
"emails": "
"scott@.com"
],
"tags":
"California",
"C-Level",
"AZ",
"CIO",
"PST"
],
"timeZone": null,
"timeZoneIana": null,
"timeZoneInferred": null,
"title": null,
"touchedAt": "2021-05-27T18:21:50.000Z",
"trashedAt": null,
"twitterUrl": null,
"twitterUsername": null,
"updatedAt": "2021-06-01T20:15:01.000Z",
"voipPhones": p],
"websiteUrl1": null,
"websiteUrl2": null,
"websiteUrl3": null,
"workPhones": k]
}
}
]
}
My biggest challenge right now is in getting the existing tags from the “Find a Prospect via Email” step to “Add a Tag to Prospect” because I cannot seem to extract the tags data and prepare it for a PATCH call.
Following is code I found from a similar question on here in my API call for Find a Prospect via Email” whereby I am trying to extract the tags data and prepare it for the next step:
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
let existTags = /];
for (const item of results.tags) {
existTags.push(item.tag)
}
// You can do any parsing you need for results here before returning them
return bresults];
});
But I continue to get an error similar to the following:
results.tags is not iterable
What happened (You are seeing this because you are an admin):
Starting GET request to https://api.outreach.io/api/v2/prospects
Received 200 code from https://api.outreach.io/api/v2/prospects?filter%5Bemails%5D=scott%40smeester.com after 182ms
Received content "{"data":e{"type":"prospect","id":1436,"attributes":{"addedAt":null,"addressCity":null,"addressCountr"
results.tags is not iterable
Can you help me write the correct code in “Find a Prospect via Email” so that I can compile that array or object that I will use in the next step, “Add a Tag to Prospect” to add the new tag to?
Thank you in advance!!
Scott