A Minimal Gmail Snooze

8 Lines of Code + A Hashtag

Sean Hickey
Understanding by Mistake

--

The annual MN Google Summit took place this weekend at Edina High School courtesy of Flipped Education. I was invited to participate in the demo slam at the end of the conference and I took the opportunity to show how one can create a fully automated snooze system for Gmail with 8 lines of code. The result is so short, it can be minified down to fit in a single tweet:

With room to spare for a hashtag!

The system works by setting up a label for snoozed messages, then creating a script to run at a specified time interval to “unsnooze” the messages by removing the snooze label and moving them back to the inbox. In this way, snoozing an email is as simple as dragging it into the snooze label.

The Nitty-Gritty

Setting up the system takes only a few minutes (and probably less if you’ve already installed Apps Script into your Google Drive). If you’re a scripter already, here’s the un-minified code you can use to unsnooze your messages. Set up a time-based trigger to run the script automatically.

function unsnooze(){
var label = GmailApp.getUserLabelByName("Snooze");
var messages = label.getThreads();
messages.map(function(m){
m.removeLabel(label);
m.moveToInbox();
});
}

If you want to use a different label name for your snoozed messages, be sure to change the “Snooze” string on the second line to match.

For detailed instructions, check out this document.

P.S. Coincidentally, as of this morning it looks like this script may soon be obsolete as Google prepares to include snooze as a standard feature!

--

--

Sean Hickey
Understanding by Mistake

CS Teacher, SBG/SBAR Evangelist, PBL Advocate, Destroyer of Curricula, and Technology Specialist at The Blake Upper School.