Created
May 8, 2020 19:53
-
-
Save jwrubel/3a35833e22707b11e33d588d2e1c7d8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Adding contacts to a box | |
* This step takes the email addresses on the To: line of the email | |
*. and sends each one to the 'Add Contact To A Box In Streak' action | |
*. This needs to be executed in javascript because Streak's Zaps do | |
* not support line items (https://zapier.com/help/create/basics/use-line-items-in-zaps) | |
*. Author: Jim Wrubel (jwrubel@innovationworks.org) | |
*/ | |
// Exclude internal staff who might be included on the email by filtering against | |
// domain names we own | |
let internalDomains = ["innovationworks.org", "alphalab.org", "alphalabgear.org", "startablepgh.org"] | |
// emails passed to this step are in a string separated by commas | |
// split them and then filter emails that match an internal domain | |
var emails = inputData.emails.split(",") | |
.filter(email => !internalDomains.some(filtered => email.includes(filtered))) | |
console.log(emails) | |
var output = [] | |
if (emails.length > 0) { | |
emails.forEach((email) => { | |
output.push({email: email}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment