4

I'm currently using Gmail Lab feature - canned responses. I have a lot of these canned responses and using their menu to find the right one, proves to be time-consuming. It would be way easier to find a canned response by:

  1. linking a canned response to a keyword
  2. using that keyword in the body or subject field. Something like this.

Would this be possible by using Gmail API or would you suggest another way to do it?

dev.e.loper
  • 35,446
  • 76
  • 161
  • 247
  • 2
    I'm not sure if Gmail API is capable of doing it but the closest that I can suggest is, use apps script to create an autoreply by filtering the gmail and sending a reply - you might want to check this [tutorial](https://ctrlq.org/code/20116-gmail-auto-replies). You can use [search syntax](https://support.google.com/mail/answer/7190?hl=en) to query for the mail. Hope this helps. – Mr.Rebot Nov 17 '16 at 14:23
  • Maybe you can try writing a grease monkey script to do that? You would have to use firefox with grease monkey installed but I think it would work. https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ – Aaron Dec 22 '16 at 21:18

2 Answers2

5

How is this workflow? Add the label "CannedResponses" to all your prepared replies. Then mark each with the particular label the reply applies to, eg 'TestLabel1'. Then as new emails come in you label them, and after that you run a script like this:

function CannedReply() {
  var label = "<mylabel>"; //eg <myLabel> = TestLabel1
  var myemail = "<me@gmail.com>";

  var responsebody = GmailApp.search(
      "label:" + label + " label:CannedResponses"
      )[0].getMessages()[0].getBody();
  var threads = GmailApp.search("label:" + label + " -label:CannedResponses label:unread");
  for (var i = 0; i < threads.length; i++) {
    for (var j = 0; j < threads[i].getMessageCount(); j++) {
      message = threads[i].getMessages()[j];
      message.reply("", {htmlBody: responsebody, from: myemail});
      GmailApp.markMessageRead(message);
    }
  }
}
Rian Rizvi
  • 9,989
  • 2
  • 37
  • 33
1

using that keyword in the body or subject field

Autohotkey would support this, it's an app that lets you map key combinations or keywords to text macros. You wouldn't be using any native Gmail features this way, including their canned responses feature, but it might suit your need well enough.

mbrewster
  • 9
  • 2