0

I have a Google Workspace Email address, and I'd like to get a webhook every time someone invites my address to an event. Is this possible?

Had a look at the Push notifications page on the Google Calendar API but I could not find what I was looking for: https://developers.google.com/calendar/api/guides/push

I can always parse the invitation email I receive but wondering if there's a way to set up a webhook

thanks

wachichornia
  • 1,178
  • 14
  • 31

1 Answers1

0

To request push notifications, you need to set up a notification channel for each resource you want to watch.

First of all you need an endpoint to receive the notification, you can use Google Apps Script for doing so as described here.

After having a valid URL, you only need to use Google Calendar API as an Advanced Service inside Google Apps Script (this is an example using Google Apps Script, but this can be reproducible in any language or using pure HTTP request):

const watchCalendarEvent = () => {
  const channel = Calendar.Events.watch(
    {
      address: "https://mywebapp.com/recieve_calendar_notification",
      id: Utilities.getUuid(),
      type: "web_hook",
    },
    /* This is a keyword for our main calendar */
    /* But you can use whatever you need */
    "primary",
    {
      /* These are not required */
      token: Utilities.getUuid(),
      expiration: Date.now() + 10e5,
    }
)}

After that, you can go to your endpoint and check if everything is going as expected.

Emel
  • 2,283
  • 1
  • 7
  • 18