I am seeking help to automate the Gmail response to new community members in an apartment complex.

  1. First, new members send/email us a new membership, including name, i.e. request as a new resident.

    How can we check this in a spreadsheet and then send them a welcome letter (welcome to community apts..).

  2. Second, if they want a pool pass, they respond/email/"re" send us another form... or text saying "requested pool pass"

    We then send them a Gmail auto response here with their pool pass number (from spreadsheet or text file)

Question: I need help/script to 1) check/compare both subject/body for keyword/names in a spreadsheet or text file (without "re:" , so we know it's new members). And then, 2) follow-up if it's a response/Re/thread so we can send them pool safety rules/pass.

after searching I found this sample and modified it...

function autoReply() {
  var interval = 300;    //  if the script runs every 5 hrs/300mins; 
  var date = new Date();
  var day = date.getDay();
  var hour = date.getHours();

    // #1 how to check text/names here?? and new message
    var threads = GmailApp.search('is:inbox subject:' + ....); 
    for (var i = 0; i < threads.length; i++) {
      threads[i].reply("Welcome new guests, please respond with request for pool pass.");

   // #2 how to check if the pool pass is requested in the response??
  for (var i = 0; i < threads.length; i++) {
       //if (is:unread AND body:"guest name" AND body:"pool pass requested" )
      if (subject == response?? && bodycontains pool pass requested)  // how to check response
      threads[i].reply("Welcome new guests, you are assigned pool area 1A.");

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.