How To Add A Snooze Button To Gmail, No Extensions Required

Whether you’re a practitioner of inbox zero or not, we all occasionally receive emails we’re not ready to act on just yet — emails we’d rather defer to tomorrow, or even next week. Here’s how to create a smart snooze button in Gmail, no extensions required, using Google’s new-ish Apps Script tool.

Photo remixed from Alan Cleaver.

Note: Google’s Corey Goldfeder posted this method on the Google Apps Developer blog and in the video above. This post is simply a more basic version of his guide for people (like me) who previously have no experience with Google Apps Script.

How It Works

Once you’ve got this all set up, using it is simple. The script will add Snooze label to your Gmail account, along with nested labels to Snooze one day, two days, three days, and so on up to seven days. When you want to snooze an email and have it reappear in your inbox at a later day, just move the email to one of your snooze labels. After the snooze period ends, the email will reappear in your inbox. Handy, right?

It works using Google Apps Script, a JavaScript-based scripting language that you can set to add special functionality to your Google applications—including Gmail, Docs, Calendar, Contacts and more. The beauty of Apps Scripts is that they run in the cloud, independent of any extension or third-party service, meaning you don’t need to install anything special and you don’t have to worry about handing your private communication over to another service.

Here’s how to set it up with your Gmail account (works with Google Apps or vanilla Gmail accounts):

Step One: Create Your Script

Apps Scripts like this Gmail Snooze script live in your Google Docs account, inside a spreadsheet. So head to Google Docs and select Create new > Spreadsheet.

Now select Tools > Script Editor. Google Docs will open a Google Apps Script window like the one below (except without all that code in it).

This is where your fancy Gmail Snooze script is going to go. So copy and paste the text below into the Code tab of the Apps Script window (and replace the myFunction code that’s there by default).

Update: If you’re having trouble with the script below, try copying and pasting this, or just the code blocks from Goldfeder’s post. It sounds like some people are having formatting problems that might be caused by our publishing system.

var MARK_UNREAD = false;
var ADD_UNSNOOZED_LABEL = false;

function getLabelName(i) {
  return "Snooze/Snooze " + i + " days";
}

function setup() {
  // Create the labels we'll need for snoozing
  GmailApp.createLabel("Snooze");
  for (var i = 1; i <= 7; ++i) {
    GmailApp.createLabel(getLabelName(i));
  }
  if (ADD_UNSNOOZED_LABEL) {
    GmailApp.createLabel("Unsnoozed");
  }
}

function moveSnoozes() {
  var oldLabel, newLabel, page;
  for (var i = 1; i <= 7; ++i) {     newLabel = oldLabel;     oldLabel = GmailApp.getUserLabelByName(getLabelName(i));     page = null;     // Get threads in "pages" of 100 at a time     while(!page || page.length == 100) {       page = oldLabel.getThreads(0, 100);       if (page.length > 0) {
        if (newLabel) {
          // Move the threads into "today's" label
          newLabel.addToThreads(page);
        } else {
          // Unless it's time to unsnooze it
          GmailApp.moveThreadsToInbox(page);
          if (MARK_UNREAD) {
            GmailApp.markThreadsUnread(page);
          }
          if (ADD_UNSNOOZED_LABEL) {
            GmailApp.getUserLabelByName("Unsnoozed")
              .addToThreads(page);
          }
        }
        // Move the threads out of "yesterday's" label
        oldLabel.removeFromThreads(page);
      }
    }
  }
}

Once you’ve pasted that into your Apps Script Editor, select File > Save and give your project a name. (I called mine Gmail Snooze.)

If all that code above makes you feel a little out of your depth, don’t worry. You don’t have to understand the code to use the script; basically it’s JavaScript that makes calls to the Gmail Services API available to Google Apps Script. (If you want to bone up on JavaScript, check out our beginner’s guide to coding.) You wouldn’t want to install an untrusted script without understanding what the code is doing, but this one comes straight from Google, and the code isn’t doing anything untoward.

Step Two: Set Up Your New Labels

Now it’s time to create your Snooze labels inside Gmail. Sure you could do this manually, but the script actually has a method called setup() that handles this task for you with a couple of clicks. Here’s how:

1. From the Select a function to run drop-down, select setup.

2. Click the Run selected function button (the blue triangle button that looks like a Play icon).

3. Your setup function will run, and you’ll be asked for permission to run this script in your Gmail account. Authorise it and wait for the script to finish running.

When the script is finished, navigate to your Gmail account (you may need to refresh if it’s already open). If everything went as planned in the script, you should now see a new Snooze label with several nested Snooze labels beneath it. You’re almost done.

Step Three: Set the Script to Run Daily

Now all that’s left to do is set the script’s moveSnoozes method to run once daily — at which time it’ll move items that you’ve snoozed back to your inbox (or another day forward in the snooze time).

1. Select Triggers > Current project’s triggers, then click the “No triggers set up” link to create a new trigger.

2. Choose moveSnoozes from the Run drop-down, Time-driven from the Events drop-down, and then set the following two drop-downs to Day timer and Midnight to 1am. Essentially what you’re doing here is setting the time when the script will examine your inbox and move snoozed items around.

3. Click Save.

Step Four: Get Your Snooze On

That’s all there is to it. Your Gmail account now how a Snooze featured baked directly in. All you have to do to use it is move any item from your inbox to a Snooze label, and you can snooze an email anywhere from one to seven days. You can move an item there via drag and drop, from the Move to drop-down menu, or using the handy label keyboard shortcut (l) followed by a quick archive shortcut (y).[imgclear]

What Else Can You Do with Apps Script?

Apps Script offers a lot of pretty powerful services for automating actions across Google apps. This is the first time I’ve really played around with it, but you can find a gallery of publicly available scripts inside Google Spreadsheets under Tools > Script Gallery. If you’ve been using Apps Script to add any cool new functionality to your Google apps — or you have a great idea for something you’d like to see done with Apps Script — let’s hear about it in the comments.


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


2 responses to “How To Add A Snooze Button To Gmail, No Extensions Required”

Leave a Reply