Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active November 10, 2023 22:24
Show Gist options
  • Save westonruter/4528421 to your computer and use it in GitHub Desktop.
Save westonruter/4528421 to your computer and use it in GitHub Desktop.
Google Apps Script for Gmail to automatically forward Google Now notes to self onto Remember the Milk

Google Apps Script for Gmail to automatically forward Google Now notes to self onto Remember The Milk, transforming the transcribed speech into Smart Add syntax, and then archiving the thread in Gmail. Create a new script in Google Drive for Gmail, paste this JS into it, customize the rtm_email variable to your own, and customize the transformations to rtm_task for Smart Add to fit your style, and then set up a trigger to invoke the function every minute. Within approximately a minute after sending yourself a note via Google Now, the reminder will be added to your RTM account!

Example dictation: Note to self to look up article about widgets for work priority 1
Smart Add transformation: Look up article about widgets #work !1

Resources

function forwardAndArchiveGoogleNowReminderstoRTM() {
var rtm_email = 'jsmith+abc123@rmilk.com';
var from_email = Session.getActiveUser().getEmail();
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
var is_from_self = messages[j].getFrom().indexOf(from_email);
if (messages[j].getSubject() === 'Note to self' && is_from_self) {
var rtm_task = messages[j].getBody();
rtm_task = rtm_task.replace(/<\/?\w+[^>]*>/g, ''); // strip out all HTML tags
// Customize these replacements to transform your speech into Smart Add syntax
// Example: Note to self priority one check the PHP code sniffer rules for work
// => !2 to check the PHP code sniffer rules #Work
rtm_task = rtm_task.replace(/\b(and )?on list\s+/, '#');
rtm_task = rtm_task.replace(/\b(and )?with tag\s+/i, '#');
rtm_task = rtm_task.replace(/\bfor work/i, '#Work');
rtm_task = rtm_task.replace(/(^|(and|with) )?(bang|priority) (1|one|won)\b/i, '!1');
rtm_task = rtm_task.replace(/(^|(and|with) )?(bang|priority) (2|two|too|to)\b/i, '!2');
rtm_task = rtm_task.replace(/(^|(and|with) )?(bang|priority) (3|three)\b/i, '!3');
rtm_task = rtm_task.replace(/^to /i, '');
rtm_task += ' ^today';
GmailApp.sendEmail(rtm_email, rtm_task, '');
GmailApp.moveThreadToArchive(threads[i]);
Logger.log(rtm_task);
}
}
}
}
@BevanR
Copy link

BevanR commented Apr 7, 2016

Does this work with Google Now Reminders?

@mzguy
Copy link

mzguy commented Nov 10, 2023

@westonruter I've been using this idea for years, with many of my personal modifications. However, a big problem is that I can no longer get my Android Google Assistant to write an email. It appears Google changed the functionality such that as of a few months ago, trying to send an email results only in "Opening Gmail..." Have you found a workaround?

@westonruter
Copy link
Author

@mzguy Sorry, I completely forgot I wrote this as I haven't been using it for many years. I'm not aware of the latest here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment