I tend to get distracted and either miss or forget the meeting alerts that Google Calendar generates, and recent changes to Mac OS notification have made the problem worse, so I decided to build a louder, more insistent alerting application using Flow. When the flow runs, it queries my Google Calendar account every minute, and when a new meeting start time gets close, it starts tracking the meeting and emitting progressively louder and longer alarms. The package provided here installs the Alerter flow but also a new Get Google Calendar Events invocable action that takes a Google Calendar identifier and a named credential that authorizes access to that calendar’s events, and returns a data structure of events.
Here’s an example of the action configuration:
Authentication & Authorization
Figuring out how to configure a Salesforce org with the necessary credentials to make API calls to Google Calendar apis was an adventure in itself. You can read about that here.
Working with the event results
On this output screen, the raw data returned from Google is displayed on the left:
Here’s the Google documentation on the Event List response.
In order to make it easier for the flow to work with the data returned in this big json blob of text, this package defines three new custom types (aka ‘Apex Types’) called GoogleCalendarEventSet, GoogleCalendarEvent, and GoogleDateTime. The action does returns the data from Google as raw JSON but it also passes back a far more practical GoogleCalendarEventSet object that contains a list of GoogleCalendarEvent objects. In the image above, the data on the right looks a little similar, but what you’re actually seeing is the readout of a collection that can be looped over in the flow.
|calendarIdentifier||the main identifier for a Google Calendar. See ‘Calendar Identifier’ below|
|credName||the name of a Named Credential that has authenticated to a Google account. See this article.|
End Time – requires RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00. This is optional. If you don’t include it, the number of events you get will be solely determined by Max Results
|startTime||String – requires RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00. If left null or empty, the current time will be used|
|maxResults||The number of results to return. Defaults to 3|
|orderBy||The sort order of the returned results. Allowable values are ‘start time’ and ‘updated’. Updated referes to last modification time (ascending).|
|queryString||this will do a free text search on summary, description, location, attendee’s displayName, attendee’s email|
For more information, see the official documentation at https://developers.google.com/calendar/api/v3/reference/events/list
Find this ID in Google Calendar settings: