Skip to content

Instantly share code, notes, and snippets.

@peterc
Created April 10, 2020 12:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterc/7bf6576e192a621969ce625ee068447d to your computer and use it in GitHub Desktop.
Save peterc/7bf6576e192a621969ce625ee068447d to your computer and use it in GitHub Desktop.
Using Zapier to check emails on Gmail and then notify us on Slack
// Using Zapier to check emails on Gmail and then notify us on Slack
const slackURL = "https://hooks.slack.com/services/XXXXXXXXXXXXX";
let mb = inputData.b;
let folder = "Unknown";
if (mb.includes('CATEGORY_FORUMS')) {
folder = "Inbox (Forums)";
}
if (mb.includes('CATEGORY_PERSONAL')) {
folder = "Inbox (Personal)";
}
if (mb.includes('CATEGORY_UPDATES')) {
folder = "Inbox (Updates)";
}
if (mb.includes('CATEGORY_SOCIAL')) {
folder = "Inbox (Social)";
}
if (mb.includes('CATEGORY_PROMOTIONS')) {
folder = "Inbox (Promotions)";
}
if (mb.includes('SPAM')) {
folder = "SPAM FOLDER";
}
let message = inputData.a + " received in " + folder;
const slackData = { text: message, channel: '#newsletter-production' };
const res = await fetch(slackURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(slackData)
});
return {done: true};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment