Skip to main content

 This post is a follow up to the post made a few weeks ago: Phantombuster to Snov.io Zap question

What I am trying to do is that when a prospect that is scraped using Phantombuster does not have an email that is found, I want to remove that prospect entirely from the data set. That way, the emails that are scraped match the prospects they belong to and can be imported into Snovio.

The data I am getting from the Phantombuster scrape looks ok. Here is how I am mapping the keys from the Phantombuster output to the Run Javascript step:

When I apply the following JavaScript code, it ends up muddling the information.

// get Input Data field names
let keys = Object.keys(inputData)
let data = ];
console.log(inputData);
// loop through each Input Data field
for (let key of keys) {
// split the contents of each Input Data field on the commas into an array
let li = inputDataakey].split(",");
for (let i=0; i<li.length; i++) {
if (typeof dataai] === "undefined") dataai] = {};
dataai][key] = li i];
// add a record number (in case we want to break the fork/loop with a Filter)
dataai].recordNumber = i+1;
}
}

for (var i=0; i < data.length; i++) {

if (dataai]["Email"] == '' || !dataai]["Email"]) dataai] = null;
}
data = data.filter(function (el) {
return el != null;
});
// preview the whole data structure in the output
console.log(data);
// output the data
output = data;

When Phantombuster cannot find an email for a particular prospect, it assigns that key a blank string. So when the Phantom runs it scrapes 10 prospects and usually there are only 4 or 5 emails that are found. 

Here is the corresponding console log for an example run:

Not really sure what is happening here, can anyone from @Zapier advise? 

Hi @trevorSkyCiv!

Let me see if one of our more code-experienced mods can help you out with this one. @ikbelkirasan @PaulKortman any ideas here? Thanks!


@nicksimard Hoping to bump this up since we haven’t heard anything from the code-experienced mods. I would imagine people that are integrating with similar flows are having a similar issue. 


@trevorSkyCiv this is a common occurrence with Zapier and how it treats arrays with empty leading values. 

 

What I’ve tried in the past is to throw in dummy data in the front so it doesn’t think the array is starting with an empty value…  so for your inputData for Email I might do something like this:

email@exmaple.com,{{Array of Email values from previous step}}

and do that for each array and then in the output you can drop the first value datav0] if needed. 
 


@PaulKortman Thanks for the message, we tried a variety of different things like this to get it to how we want it, but it still seems like there is a bug in the backend of Zapier and the Phantombuster Zap step. Overall from how we understand it, the issue is with the Input Data mapping part. If there are empty entries, inputData comes out misaligned:

 

After this runs, instead of passing empty strings under the “Email” key, they are deleting that index altogether. This creates the mismatch in inputData between email and first name, as shown below:

Not sure if that changes anything or if this is the same as the original question, but we are really hoping to figure this out since it would make a huge difference in our operations. 


@trevorSkyCiv this is still the same problem… you have empty values in the begining of your array

 

You need to put something in front of that and maybe it will work, so if the value of email is currently set to

{{Result Object Mail From Drop Contact}}

You need to change it to be:

fake@email.com,{{Result Object Mail From Drop Contact}}

And then add a leading fake value for each of your variables… is First Name, Last Name, Company name, etc. That will help line things up. 

The key is that Zapier does not handle arrays with an empty value as the first item… it collaposes the first empty values so in your example the 4th email address will show up as the first, because 1, 2, and 3 are empty so Zapier collapses those and just skips right to the 4th value in the array.

 

When Zapier does this it does a similar behavior to the second array (First name) but since the first value in that array has a non-empty value then it doesn’t skip it, so your 4th value in your email address is now the first and the first value in your first name is also first, so thus things do not line up.

 

If you;d rather pay for a consulting fee so we can do this live over zoom let me know (send me a direct message) and I’ll respond with a link to book a call with me so we can work through what might be tricky/difficult to understand here.