Zapier - Google Calendar API

193 views
Skip to first unread message

Kévin Rabesaotra

unread,
Apr 28, 2021, 9:15:11 AM4/28/21
to Google Apps Script Community
Hi folks,

I hope you are doing well. 

I'm a big fan of zapier, and I'm really impressed with what they do. 
I've seen with the Google Calendar API they succeed to do amazing stuff.
Indeed, they are able to
  • get notification when a meeting ends
  • get notification when a meeting starts
  • get notification when a new event invite is received
  • get notification when an event is canceled
I try to build an app around that stuff and I would like to not use Zapier. Does any of you have an idea of how they built this notification system? I have struggled to find the right API route to do those 4 things.
Screenshot 2021-04-28 at 15.11.35.png

Alan Wells

unread,
Apr 28, 2021, 11:09:31 AM4/28/21
to Google Apps Script Community
To watch for changes to a Google Calendar there are two possibilities.

  • Install a trigger - Script Service - Class CalendarTriggerBuilder
  • Events Watch - Calendar API
The Script Service is a service that is "built-in" to Apps Script.  
The Calendar API can be used with either the Advance Service or REST API.
The CalendarApp service doesn't have a method to set-up a watch.

The documentation:
The trigger will tell you when there is a change, but it won't tell you what the change is.

Quote from docs:

Calendar triggers fire when a user's calendar events are updated (created, edited, or deleted).

These triggers do not tell you which event changed or how it changed. Instead, they indicate that your code needs to do an incremental sync operation to pick up recent changes to the calendar. For a full description of this procedure, see the Synchronizing resources guide for the Calendar API.

End Quote

I have not used either the trigger or the API Watch.  I don't see anything in the documentation that explains what the API watch provides for information.
I guess the only way to know is to set it up, create and event, add a guest, and see what your code returns.

Unfortunately, there doesn't seem to be much detailed information on this subject.
I did find a StackOverflow post:

Joshua Snyder

unread,
Apr 28, 2021, 4:53:53 PM4/28/21
to Google Apps Script Community
^ This is a very good summary of the two options.

There are some implementation problems when you get started with this stuff though.

Unfortunately those calendar triggers are subject to the general problems of failing triggers on V8 reported in a number of Issue reports. This means you'll need to run your project on the DEPRECATED_ES5 runtime, which may have compatibility issues.

This leaves you with the Watch API, which will notify you of changes, but you'd need to receive those notifications somewhere (an API endpoint) and the setup can be a bit cumbersome. Don't have much experience with this, but given the issue with triggers it might be the best way to go.

Kévin Rabesaotra

unread,
Apr 30, 2021, 12:43:48 PM4/30/21
to google-apps-sc...@googlegroups.com
Hey folks

thanks for your answer. Your answers are definitely useful. But from the doc I read, there is nothing to be notified when an event is done. Not even the watch API does that, so I'm really curious how they implemented that at Zapier.

Anything I missed?

Kevin

Kévin


--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-community+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/943cad65-c0a7-4758-8f27-6948c485cfb7n%40googlegroups.com.

Alan Wells

unread,
Apr 30, 2021, 12:59:36 PM4/30/21
to Google Apps Script Community
That's a good question about how Zapier is able to do it if the API doesn't provide the means to.
Did you look at the documentation for synchronizing client and server calendar data?
If both the calendar at Google and the setting somewhere else is in sync,
then I believe that they'd have the same sync token.
But if the tokens are different, then your code can request all the updates since the token that you have.
I've never used this, so I'm just guessing after scanning the docs very quickly.
The documentation doesn't even explain what the data in the incremental changes includes or what format it's in.
So, I guess you learn it by trial and error.
Zapier could be keeping their own databases of your calendar data in order to sync it that way.

To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.

Joshua Snyder

unread,
May 2, 2021, 4:03:29 PM5/2/21
to Google Apps Script Community
My guess would be that they store some metadata on calendar events using the above syncing method and then internally trigger tasks based on when those events start or end.

Shouldn't be too difficult to implement. I've worked with using syncTokens to keep a local copy of some information in a users Google Calendar and it didn't take much to set it up. Happy to help out if you want to go this route.

Kévin Rabesaotra

unread,
May 3, 2021, 8:10:46 AM5/3/21
to google-apps-sc...@googlegroups.com
Hey Joshua,

Thanks for your answer! Ok got it, it was what I suspected, as the Google Calendar API didn't offer that.

As I started to code not long ago, I finished a bootcamp, I still have some struggle to understand the Google API. I successfully implemented a Google OAuth Sign-in and it was pretty painful!

Right now I'm exploring what I could potentially implement for my new side project, I will come back to you in the next couple of days if I need help.

Kevin

Kévin


On Sun, May 02, 2021 at 22:03:28, Joshua Snyder <jos...@mindful.ai> wrote:
My guess would be that they store some metadata on calendar events using the above syncing method and then internally trigger tasks based on when those events start or end.

Shouldn't be too difficult to implement. I've worked with using syncTokens to keep a local copy of some information in a users Google Calendar and it didn't take much to set it up. Happy to help out if you want to go this route.

On Friday, April 30, 2021 at 6:59:36 PM UTC+2 aj.a...@gmail.com wrote:
That's a good question about how Zapier is able to do it if the API doesn't provide the means to.
Did you look at the documentation for synchronizing client and server calendar data?
If both the calendar at Google and the setting somewhere else is in sync,
then I believe that they'd have the same sync token.
But if the tokens are different, then your code can request all the updates since the token that you have.
I've never used this, so I'm just guessing after scanning the docs very quickly.
The documentation doesn't even explain what the data in the incremental changes includes or what format it's in.
So, I guess you learn it by trial and error.
Zapier could be keeping their own databases of your calendar data in order to sync it that way.

On Friday, April 30, 2021 at 12:43:48 PM UTC-4 kevin.ra...@gmail.com wrote:
Hey folks

thanks for your answer. Your answers are definitely useful. But from the doc I read, there is nothing to be notified when an event is done. Not even the watch API does that, so I'm really curious how they implemented that at Zapier.

Anything I missed?

Kevin

Kévin


Kévin Rabesaotra

unread,
May 4, 2021, 3:28:53 AM5/4/21
to google-apps-sc...@googlegroups.com
Hi Joshua and Alan,

I briefly discussed with an engineer from Zapier. Here his answer.
One thing I'm not sure I follow, what does it mean when a new eventID is triggered? Is it inside Google Calendar they put a eventID:STARTED?
Do they save the google calendar event somewhere?


Kévin


On Mon, May 03, 2021 at 14:10:41, Kévin Rabesaotra <kevin.ra...@gmail.com> wrote:
Hey Joshua,

Thanks for your answer! Ok got it, it was what I suspected, as the Google Calendar API didn't offer that.

As I started to code not long ago, I finished a bootcamp, I still have some struggle to understand the Google API. I successfully implemented a Google OAuth Sign-in and it was pretty painful!

Right now I'm exploring what I could potentially implement for my new side project, I will come back to you in the next couple of days if I need help.

Kevin

Kévin

Joshua Snyder

unread,
May 4, 2021, 7:11:40 AM5/4/21
to Google Apps Script Community
Hi Kevin,

Great to hear that you have recently got into developing and are working on some side projects! Congratulations on completing the Sign-In flow, that can be quite challenging with all of the domain-specific authentication jargon.

I can't quite decipher that answer, but here is what I think the engineer is saying:

Zapier store a Zapier Event ID for each Google Calendar event that is a combination of the Google Event ID, the start time and the end time of the event. An endpoint then watches for changes.

On receipt of a change, it requests the events and generates Zapier IDs for them, and checks those IDs against those currently stored. If there is a new ID present, that means there has either been a new event, or an event has changed start or end time.

I don't think this is exactly what you want, given you want notifications when events start/end, rather than when their start/end is changed. Basically, there doesn't seem to be a way to do this without storing the information about the events.

Let me know if I can explain all that better!

Kévin Rabesaotra

unread,
May 6, 2021, 1:26:41 PM5/6/21
to google-apps-sc...@googlegroups.com
Basically, there doesn't seem to be a way to do this without storing the information about the events.

What does it mean exactly storing the information? Do you mean they potentially save the data in mongoDB for example?

Kévin


On Tue, May 04, 2021 at 13:11:40, Joshua Snyder <jos...@mindful.ai> wrote:
Hi Kevin,

Great to hear that you have recently got into developing and are working on some side projects! Congratulations on completing the Sign-In flow, that can be quite challenging with all of the domain-specific authentication jargon.

I can't quite decipher that answer, but here is what I think the engineer is saying:

Zapier store a Zapier Event ID for each Google Calendar event that is a combination of the Google Event ID, the start time and the end time of the event. An endpoint then watches for changes.

On receipt of a change, it requests the events and generates Zapier IDs for them, and checks those IDs against those currently stored. If there is a new ID present, that means there has either been a new event, or an event has changed start or end time.

I don't think this is exactly what you want, given you want notifications when events start/end, rather than when their start/end is changed. Basically, there doesn't seem to be a way to do this without storing the information about the events.

Let me know if I can explain all that better!

On Tuesday, May 4, 2021 at 9:28:53 AM UTC+2 kevin.ra...@gmail.com wrote:
Hi Joshua and Alan,

I briefly discussed with an engineer from Zapier. Here his answer.
One thing I'm not sure I follow, what does it mean when a new eventID is triggered? Is it inside Google Calendar they put a eventID:STARTED?
Do they save the google calendar event somewhere?


Kévin


To unsubscribe from this group and all its topics, send an email to google-apps-script-community+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.

Kévin Rabesaotra

unread,
May 6, 2021, 3:01:01 PM5/6/21
to google-apps-sc...@googlegroups.com
I've done an attempt to see what I receive (from results.data). Where is the eventId? should I use etag as eventId?



Kévin


On Thu, May 06, 2021 at 19:26:37, Kévin Rabesaotra <kevin.ra...@gmail.com> wrote:
Basically, there doesn't seem to be a way to do this without storing the information about the events.

What does it mean exactly storing the information? Do you mean they potentially save the data in mongoDB for example?

Kévin

Joshua Snyder

unread,
May 6, 2021, 4:42:36 PM5/6/21
to Google Apps Script Community
Hi Kévin,

is this the response from the Google Calendar API or from a Zapier API?

If it is the response from the Calendar API it should contain an id field which refers to the events unique ID.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.

Joshua Snyder

unread,
May 6, 2021, 4:46:34 PM5/6/21
to Google Apps Script Community
Precisely. I can't think of a solution where you don't store the event id's and their start/end times in a database, you can then use those to trigger some code to run at the start/end of the event.

I hope it goes well!

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/8cf0210c-b0a6-4aa8-8ac3-30c59907874en%40googlegroups.com.

Kévin Rabesaotra

unread,
May 7, 2021, 10:37:36 AM5/7/21
to google-apps-sc...@googlegroups.com
If it is the response from the Calendar API it should contain an id field which refers to the events unique ID.

Ok then I need to take a better look at the payload then :) 

Kévin


On Thu, May 06, 2021 at 22:42:36, Joshua Snyder <jos...@mindful.ai> wrote:
Hi Kévin,

is this the response from the Google Calendar API or from a Zapier API?

If it is the response from the Calendar API it should contain an id field which refers to the events unique ID.

On Thursday, May 6, 2021 at 9:01:01 PM UTC+2 kevin.ra...@gmail.com wrote:
I've done an attempt to see what I receive (from results.data). Where is the eventId? should I use etag as eventId?



Kévin


To unsubscribe from this group and all its topics, send an email to google-apps-script-community+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-community+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.

Kévin Rabesaotra

unread,
May 7, 2021, 10:38:54 AM5/7/21
to google-apps-sc...@googlegroups.com
Precisely. I can't think of a solution where you don't store the event id's and their start/end times in a database, you can then use those to trigger some code to run at the start/end of the event.

Wow that's really interesting, I thought they only used the google calendar API. I'm less confortable to save users data! But let's try just to learn more things :) 

Kévin


On Thu, May 06, 2021 at 22:46:34, Joshua Snyder <jos...@mindful.ai> wrote:
Precisely. I can't think of a solution where you don't store the event id's and their start/end times in a database, you can then use those to trigger some code to run at the start/end of the event.

I hope it goes well!

On Thursday, May 6, 2021 at 7:26:41 PM UTC+2 kevin.ra...@gmail.com wrote:
Basically, there doesn't seem to be a way to do this without storing the information about the events.

What does it mean exactly storing the information? Do you mean they potentially save the data in mongoDB for example?

Kévin


To unsubscribe from this group and all its topics, send an email to google-apps-script-community+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-community+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/1ZAXsK4Pkls/unsubscribe.

Kévin Rabesaotra

unread,
May 10, 2021, 10:11:24 AM5/10/21
to google-apps-sc...@googlegroups.com
I've found the eventId. I needed to add this field as parameter to retrieve the data.

One quick question, let's say I save the event in MongoDB. I guess I would need to use that kind of stuff to run a trigger from my server side

Cheers,


Kévin


On Fri, May 07, 2021 at 16:38:49, Kévin Rabesaotra <kevin.ra...@gmail.com> wrote:
Precisely. I can't think of a solution where you don't store the event id's and their start/end times in a database, you can then use those to trigger some code to run at the start/end of the event.

Wow that's really interesting, I thought they only used the google calendar API. I'm less confortable to save users data! But let's try just to learn more things :) 

Kévin

Reply all
Reply to author
Forward
0 new messages