How NOT to integrate Google Calendar with your product

gautamsawhney

Gautam Sawhney

Posted on March 17, 2020

How NOT to integrate Google Calendar with your product

Google calendar has decent documentation for most of its products and supports most of the libraries, even then, it's confusing enough to take the wrong approach while integrating with google calendar.

When I set out to build calendar integration for one of my products, I had never thought that it would end up becoming so complicated to do things which I had initially thought to be simple.

Product Requirements

  1. During Signup/Login ask for permission to view/edit/create the events in their primary google calendar.
  2. Fetch the calendar events(both recurring and 1 time) and show them to the users so that they can add more details to it(specific to the product).
  3. Keep in sync with any new events that are created.
  4. Sync existing events between the product and the calendar.
  5. Updating the correct recurring events in google calendar for any updates done to them in my product.

Remember that, my product required 2-way sync of events.

The Incorrect Approach

During my research, most of the blog posts I read pointed to using the Calendar Events List API and my brain started to work in that direction. I took the following approach which is inefficient and unscalable -

  1. Integrated the Calendar Events List API which got me the event information for all the upcoming events.
  2. Saved the ones which matched as per the algorithm of the product
  3. If the user performed any update to these events then update the calendar events accordingly(changes to date/time/description)
  4. Write a Cron job which runs every 30 minutes to check if any new events were added/existing events changed(biggest blunder) for all the users in the database.

The Correct Approach

Soon, I realised that this was not the most efficient and scalable way to achieve the results I wanted.
I dug deeper into the google documentation to realize that there is a synch API which helps in incremental synch of data and works as a webhook. This is what made complete sense and would fit my requirements perfectly.
I am going to talk about this approach in a new series. Stay Tuned

💖 💪 🙅 🚩
gautamsawhney
Gautam Sawhney

Posted on March 17, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related