I want to trigger some script when new calendar event is created in Google Calendar (say calling some rest API that enters event information to my database). I do not want any kind of UI that triggers the script.
Is it possible to achieve this using Google gadget since I do not want any UI? I would really appreciate the help as I am new to Google API.
Thanks a lot
Shubhra
Triggers let Apps Script run a function automatically when a certain event, like opening a document, occurs. Simple triggers are a set of reserved functions built into Apps Script, like the function onOpen(e) , which executes when a user opens a Google Docs, Sheets, Slides, or Forms file.
Calendar API has something like notifications. See this link: Push Notifications. From documentation:
The Google Calendar API provides push notifications that let you watch for changes to resources. You can use this feature to improve the performance of your application. It allows you to eliminate the extra network and compute costs involved with polling resources to determine if they have changed. Whenever a watched resource changes, the Google Calendar API notifies your application.
Google Calendar API (relevant docs) provides a watch
endpoint that allows you to specify a webhook upon certain events.
To set up the webhook, you can call the Calendar API endpoint a POST request to https://www.googleapis.com/calendar/v3/calendars/calendarId/events/watch
with the body
{
"id": string
"type": string,
"address": string
}
The "address"
field tells Calendar what endpoint to call when there is a new Calendar event. You'll need to create and host this endpoint yourself.
Another option is to use a service like Zapier, which has fantastic integrations for Google Calendar and makes setting up a listener (i.e. a trigger) and corresponding action very simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With