Trigger automated meeting invite reminders using Apps Script

Send a follow-up email to all undecided participants of a meeting that you've scheduled via Google Calendar using Apps Script.

Trigger automated meeting invite reminders using Apps Script
Trigger automated meeting invite reminders using Apps Script

if you're one of those people whose role involves scheduling a lot of meetings - well, congratulations! people most likely already hate you.

credits: GIPHY
credits: GIPHY

don't worry though, here's something that may make your job easier but more importantly, piss those people who you schedule meetings with, even more.

before we begin, you might also be interested in creating a meetings heatmap view using google's calendar chart and apps script.

alright, let me get to it then. hit me on @schoraria911 if you've come across any of the following rationale that folks with whom you may've wanted to meet - shared a meeting invite & who didn't respond to 'em - given you somewhere along the way:

  • "oh, looks like i missed that email"
  • "i'd just opened your meeting invite and was about to click yes, but forgot to"
  • "i don't think i was required in that discussion so chose not to attend - didn't I say no?"

and my personal favourite:

  • "i didn't get that invite notification at all - can you send me another one?"
credits: GIPHY
credits: GIPHY

obviously, there are some sets of notification that you can incorporate well within the invite itself -

calendar-inbuilt-notification
calendar-inbuilt-notification

however, you'd have no control over content or mode of delivery (email, hangouts/slack ping, sms or call based notification) from there - take a moment to consider all the filters you may have in your very own gmail to avoid some of these default, system-generated alert/notification emails.

credit: GIPHY

so, here's a piece of code that you could schedule for every morning (preferably before your official work hours start) to be triggered, such that the script could iterate through every single meeting event that you've scheduled (i.e. where you're the "organiser") for the day and send an email to all those invitees who've neither accepted nor declined (even excluding the maybe'd ones too) to said invites.

you could access the entire codebase from my github repository here or make a copy of the original script form this file here.

to automate the entire task, simply run the cronSetup function once, after choosing the right set of configurations as that way, the script would get triggered every single day against the atHour that you'd have set.

function reminders() {
  var events = CalendarApp.getDefaultCalendar().getEventsForDay(new Date());
  for (var i = 0; i < events.length; i++) {
    var event = events[i];
    if (event.isOwnedByMe()) {
      var guests = event.getGuestList(false);
      for (var j = 0; j < guests.length; j++) {
        var guest = guests[j];
        if (guest.getGuestStatus() == 'INVITED') {
          var meetingName = event.getTitle();
          var meetingDescription = event.getDescription();
          var meetingID = event.getId().split('@')[0];
          var guestMail = guest.getEmail();
          var eventID = Utilities.base64Encode(meetingID + ' ' + guestMail);
          var meetingLink = 'https://www.google.com/calendar/render?action=VIEW&eid=' + eventID;
          var meetingTime = Utilities.formatDate(
            new Date(event.getStartTime()),
            Session.getScriptTimeZone(),
            'HHmm'
          );
          var msgSubject = 'Reminder for ' + meetingName + ' | ⏰: ' + meetingTime + ' hrs.';
          var msgBody = 'Hi there!\n\n'
          + 'You\'ve not responded to my invite for today\'s conversation on -\n⚡ ' + meetingName
          + '.\n\nPlease either ✅ or ❌ the invite so we could plan accordingly -\n' + meetingLink;
          if (meetingDescription.length > 0) {
            msgBody = msgBody + '\n\nHere\'s the agenda:\n\n' + meetingDescription;
          }
          msgBody = msgBody + '\n\nHope to see you there.\n\nCiao!'
          GmailApp.sendEmail(
            guestMail,
            msgSubject,
            msgBody,
            {
              name: 'Reminder BOT',
              cc: Session.getEffectiveUser().getEmail()
            }
          );
        }
      }
    }
  }
}

function cronSetup() {
  ScriptApp.newTrigger('reminders')
  .timeBased()
  .everyDays(1)
  .atHour(10)
  .nearMinute(1)
  .create();
}
Code.gs

think of this as a baseline where instead of using gmail services, you could now also trigger a slack alert or send a ping to any other platform that would annoy the shit out of your peeps.

learnings