We have lots of things to keep track of and lots of places that we get pings. Also, no one checks emails. Here's a small integration to get Slab notifications to ping you on Discord.
- Create some sort of test server for yourself (I assume a lot of us already have one)
- Create a channel for the pings to go in
- Create a webhook in the channel: channel settings -> Webhooks -> Create Webhook
- Name it what you want, give it an icon, and copy the
Webhook URL
at the bottom
- Go to https://script.google.com/u/1/home/my
- Switch to your Discord GSuite user if necessary
- Create a new project
- Copy the following code into your script
// Thanks to Joey for an updates script!
var WEBHOOK_URL = ''
// discord limits us to 2000 char, but that seems exessive
var MAX_BODY_LENGTH = 1000
// Slab notifications to Discord
function slabPing() {
// Search for any notification emails from slab in your inbox
var emails = GmailApp.search('from:notifications@slab.com in:inbox');
// For each email we find
for each (thread in emails) {
// Get the subject of the email, and create form data for our webhook
var messages = thread.getMessages();
var subject = thread.getFirstMessageSubject();
var lastMessage = messages[messages.length - 1];
var body = lastMessage.getPlainBody()
.replace('[image: Slab Logo]', '')
.replace(subject, '**' + subject + '**')
.trim()
.substring(0,MAX_BODY_LENGTH);
if (body.length === MAX_BODY_LENGTH) {
body = body.substring(0, MAX_BODY_LENGTH - 1) + '…'
}
var formData = {
'content': body
};
// Send a POST request with the data to our Webhook URL
var options = {
'method' : 'post',
'payload' : formData
};
var res = UrlFetchApp.fetch(WEBHOOK_URL, options);
var resCode = res.getResponseCode();
if (resCode >= 200 && resCode < 400) {
// Mark as read so this doesn't come up again
thread.moveToArchive();
}
}
}
- Save as a script; I called mine
Code.gs
- Go to https://script.google.com/u/1/home/triggers
- Create a new trigger, choosing the
slabPing
function with a Time-driven event source and set it to run how ever often you'd like
Voila. This script will give you notifications for:
- Comments on your docs
- People mentioning you
- Reactions to your docs