Create Google Calendar Feed

User Intent

"How do I sync Google Calendar events? Show me Google Calendar feed configuration."

Operation

SDK Method: createFeed() with FeedTypes.Calendar OAuth: Required


Code Example (TypeScript)

import { Graphlit } from 'graphlit-client';
import {
  FeedTypes,
  FeedServiceTypes,
  GoogleCalendarsInput,
} from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Enumerate available calendars for the connected Google account
const calendarsResponse = await graphlit.queryGoogleCalendars({
  clientId: process.env.GOOGLE_CLIENT_ID!,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
  refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
});

const calendars = calendarsResponse.googleCalendars?.results ?? [];

if (calendars.length === 0) {
  throw new Error('No calendars available for the provided credentials');
}

const calendarId = calendars[0]?.calendarId!;
console.log(`Using calendar: ${calendars[0]?.calendarName} (${calendarId})`);

const feed = await graphlit.createFeed({
  name: 'Engineering Calendar',
  type: FeedTypes.Calendar,
  calendar: {
    type: FeedServiceTypes.GoogleCalendar,
    token: process.env.GOOGLE_OAUTH_TOKEN!,
    calendarId,
    readLimit: 100,
  },
  // Optional: add workflow for content processing
  // workflow: { id: workflow.createWorkflow.id }
});

console.log(`Created Google Calendar feed: ${feed.createFeed.id}`);

Last updated

Was this helpful?