A hacky solution to put GrabCAD notifications in Slack. Supposed to run on heroku.
-
GrabCAD sends an email to a Gmail account. You can turn on emails in the user settings.
-
A Google Apps Script forwards all GrabCAD emails to
[email protected]
(it is essentially impossible to use Gmail filters to forward emails to IFTTT). Script setup instructions below. -
An IFTTT applet takes the GrabCAD emails, and then sends the BodyHTML as raw text to the
grabcad-slack-notifier
-
grabcad-slack-notifier
does its best to parse out the comment/file changes from the email HTML -
grabcad-slack-notifier
figures out what should be sent in Slack, and then makes aPOST
request to another IFTTT applet, with what should be sent in slack under the keyvalue1
in the JSON payload -
This separate IFTTT applet takes
value1
and finally sends it to Slack
You could cut out the last step if you could get grabcad-slack-notifier
to directly send the text to
Slack, if you had some kind of admin privileges on the workspace. Sadly, the author at the time did not, so
IFTTT nonsense had to suffice.
function autoForward() {
var label = 'GrabCAD';
var recipient = '[email protected]';
var interval = 1; // if the script runs every minute; change otherwise
var date = new Date();
var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval; // find what time it was a minute ago
var threads = GmailApp.search('label:' + label + ' after:' + timeFrom); // search for emails with appropriate label, came after a minute ago
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
messages[messages.length - 1].forward(recipient); // forward the last
}
}
You can go to the Google Apps Script Website to set up this script. Make sure to set a trigger so that it runs every minute.
IFTTT, Heroku, and GrabCAD accounts are under [email protected]
.
The passwords for the accounts are under the drafts of that Gmail account. Make sure that [email protected]
is added
to all GrabCAD projects that you want to be updated in Slack (#cad-updates
)