Created
April 10, 2020 12:59
-
-
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
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
// 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