Skip to content

Instantly share code, notes, and snippets.

@peterc
Created November 2, 2020 23:27
Show Gist options
  • Save peterc/6b8471093f2f5ae3fd864fdad82d0c9c to your computer and use it in GitHub Desktop.
Save peterc/6b8471093f2f5ae3fd864fdad82d0c9c to your computer and use it in GitHub Desktop.
zapier function to take gmail input and determine inbox type
// a is the 'from name'
// b is the 'labels'
// you set these up in zapier after having gmail as a source
const slackURL = "https://hooks.slack.com/services/...";
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: '#whateverchannel' };
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