Automate Birthday Reminders with Google Forms and Calendar

Introduction

Let's create something interesting where we can integrate google forms and Calendar to send reminders. Just out of curiosity, I ended up doing this. Hope you all will love it.

Let's get into the Implementation part.

1. Create a Google Form

  • Go to Google Forms (https://docs.google.com/forms) and create a new form.
  • Add a "Short Answer" question for the person's name.
  • Add a "Date" question for the birthdate.
  • Customize the form as desired.
  • Save the form.

2. Obtain the Google Form's URL

  • Go to the Google Forms editor.
  • Click the "Send" button (paper plane icon) in the top-right corner.
  • Copy the form URL.

3. Create a Google Apps Script

  • Open Google Drive (https://drive.google.com) and create a new Google Apps Script.
  • Replace the default code in the script editor with the following code.
  • function onFormSubmit(e) {
      var response = e.response.getItemResponses();
      var name = response[0].getResponse();
      var birthdate = response[1].getResponse();
    
      // Create a Google Calendar event for the reminder each year
      var calendar = CalendarApp.getDefaultCalendar();
      var eventTitle = "Birthday Reminder: " + name +"   "+birthdate;
    
      // Loop to set reminders for each of the next 10 years
      for (var i = 0; i < 50; i++) { // Setting reminders for the next 50 years
        var birthdateThisYear = new Date(birthdate); // Clone the birthdate object
        birthdateThisYear.setFullYear(birthdateThisYear.getFullYear() + i); // Set the year to the current loop iteration year
    
        var reminderDate = new Date(birthdateThisYear.getTime() - (4 * 24 * 60 * 60 * 1000)); // 4 days before birthdate
        reminderDate.setHours(7, 0, 0, 0); // Set the reminder time to 7 am
    
        calendar.createEvent(eventTitle, reminderDate, reminderDate);
      }
    }

4. Save the Google Apps Script

  • Give the script a name.
  • Click on the floppy disk icon to save the script.

5. Set up the Google Apps Script trigger

  • Click on the clock icon (Triggers) in the script editor toolbar.
  • Click on "Add Trigger" in the bottom-right corner.
  • Configure the trigger:
  • Choose the function name "onFormSubmit".
  • Choose "From form" for the "Select event source" option.
  • Select the Google Form you created in Step 1.
  • Save the trigger.

6. Connect the Google Form to the Google Apps Script

  • Open the Google Form editor.
  • Click on the "3-dot" menu button in the top-right corner.
  • Select "Script editor".
  • In the script editor, click on "Edit" and select the Google Apps Script you created in step 3.

Now, when someone submits the Google Form with their name and birthdate, the onFormSubmit function in the Google Apps Script will be triggered. It will create a Google Calendar event for the reminder with the person's name and birthdate.

Conclusion

We have created reminder automation using google forms and Calendar. Hope this finds interesting to you all.