5 min readUpdated Mar 2, 2026

Google Calendar Integration

The Google Calendar Integration allows users to interact with Google Calendar APIs, enabling functionalities such as listing calendars, creating new events, updating events, deleting events, and managing user access tokens securely. This integration is essential for any application that requires calendar functionality as it allows for seamless synchronization and management of events.

Settings

Class Constructor Parameters

  1. encryptedRecord

    • Type: string
    • Purpose: This parameter holds encrypted credentials for accessing the Google Calendar API. Changing this parameter should only be done when different credentials are used, typically after a re-authentication process.
    • Default Value: There is no default; it must be provided during instantiation.
  2. serviceId

    • Type: string
    • Purpose: This identifies the specific service under which the integration operates. It may be used for tracking usage or permissions associated with the Google Calendar service.
    • Default Value: None; it must be assigned a valid service identifier.
  3. clientId

    • Type: string
    • Purpose: This is the Client ID obtained from the Google Developer Console, which identifies your application to the API. If this value changes, it may affect how authentication flows through the application.
    • Default Value: None; must be explicitly defined during configuration.
  4. credentialId

    • Type: string
    • Purpose: This is used to reference previously stored user credentials in the database. Changing this affects which user's credentials are being accessed.
    • Default Value: None; must be provided on initialization.

API Interaction Settings

Method-Specific Settings

  1. listEvents() Options:
    • calendarId

      • Type: string
      • Default: 'primary'
      • Purpose: The identifier for the calendar to fetch events from. Change it to get events from different calendars.
    • timeMin

      • Type: string (ISO 8601 format)
      • Default: None
      • Purpose: Used to filter events that start after this time. Allows granularity in event querying.
    • timeMax

      • Type: string (ISO 8601 format)
      • Default: None
      • Purpose: Similar to timeMin, but specifies the upper limit for event start times.
    • query

      • Type: string
      • Default: None
      • Purpose: Enables free-text search of events. Useful for filtering events based on title or description.
    • maxResults

      • Type: numeric
      • Default: 50 (maximum is 2500)
      • Purpose: Sets the maximum number of results to return; changing this can limit or increase the volume of data retrieved.
    • pageToken

      • Type: string
      • Default: None
      • Purpose: Used for paginating through results when more than maxResults are available.
    • singleEvents

      • Type: boolean
      • Default: true
      • Purpose: Expands recurring events into individual instances when retrieving events.
    • orderBy

      • Type: string
      • Choices: 'startTime' or 'updated'
      • Default: 'startTime'
      • Purpose: Determines how the returned events are sorted.

How It Works

  1. Initialization: The integration is instantiated with encrypted credentials and parameters necessary for API interactions.
  2. Token Management: Automatically retrieves and refreshes the access token using OAuth 2.0. It stores token expiry information to prevent authentication errors in subsequent calls.
  3. API Requests: Uses the request method to interact with Google Calendar API endpoints, passing appropriate headers and body content when needed.
  4. Event Handling: Methods for listing, creating, updating, and deleting events invoke the respective API endpoints, handling responses and error logging as required.
  5. Credential Management: Updates and encrypts user credentials securely in the database, ensuring the latest tokens and information are stored.

Data Expectations

The Google Calendar Integration expects well-defined structures for API requests and responses:

A well-formed request will result in JSON responses that either confirm actions (like creating an event) or return relevant data (like listing events).

Use Cases & Examples

Use Cases

  1. Corporate Event Management: A project management platform could automate the scheduling of meetings by integrating with Google Calendar to create events based on project timelines.
  2. Personal Assistant Applications: Create an app to notify users about upcoming appointments by fetching events from their Google Calendar.
  3. Team Collaboration Tools: Automatically add time blocks for team members based on their calendar availability for meetings and collaboration.

Example Configuration

Use Case: Corporate Event Management

A company wants to automate the scheduling of project-related meetings based on a standard calendar for all team members. The settings for listing and creating events through Google Calendar could be configured as:

javascript
const googleCalendarIntegration = new GoogleCalendarIntegration(encryptedRecord, serviceId, clientId, credentialId);

// List project calendars
async function listProjectCalendars() {
    try {
        const calendarList = await googleCalendarIntegration.listCalendars();
        console.log('Available Calendars: ', calendarList.items);
    } catch (error) {
        console.error('Error fetching calendars: ', error);
    }
}

// Creating a new project event
async function createProjectEvent(eventDetails) {
    try {
        const calendarId = 'project-team-calendar'; // Sample calendar ID
        const eventData = {
            summary: eventDetails.title,
            description: eventDetails.description,
            start: {
                dateTime: eventDetails.startTime, // e.g., '2023-10-25T10:00:00-07:00'
                timeZone: 'America/New_York'
            },
            end: {
                dateTime: eventDetails.endTime, // e.g., '2023-10-25T11:00:00-07:00'
                timeZone: 'America/New_York'
            }
        };
        
        const createdEvent = await googleCalendarIntegration.createEvent(calendarId, eventData);
        console.log('Created Event: ', createdEvent);
    } catch (error) {
        console.error('Error creating event: ', error);
    }
}

This script would allow the company to list all project-related calendars and automate the creation of relevant events as projects evolve, ensuring all team members are aware of key meetings.