Create Gmail Feed

User Intent

"How do I sync Gmail messages? Show me Gmail feed configuration."

Operation

SDK Method: createFeed() with FeedTypes.Email Auth: Google OAuth tokens


Code Example (TypeScript)

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

const graphlit = new Graphlit();

const feed = await graphlit.createFeed({
  name: 'Gmail Inbox',
  type: FeedTypes.Email,
  email: {
    type: FeedServiceTypes.GoogleEmail,
    google: {
      type: EmailListingTypes.Past,
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
      refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
      readLimit: 100,
      inboxOnly: true,
      excludeSentItems: true
    },
    includeAttachments: true,
  },
  // Optional: add workflow for content processing
  // workflow: { id: workflow.createWorkflow.id }
});

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

Configuration

type: EmailListingTypes.Past or EmailListingTypes.New readLimit: Number of emails to sync inboxOnly: Only sync inbox (excludes other labels) excludeSentItems: Exclude sent messages includeSpam: Include spam folder (default: false) includeDeletedItems: Include trash (default: false) includeAttachments: Download email attachments filter: Gmail search filter (e.g., "from:[email protected] has:attachment")


Gmail OAuth Setup

  1. Create project in Google Cloud Console

  2. Enable Gmail API

  3. Create OAuth 2.0 credentials (Web application)

  4. Add redirect URI

  5. Get refresh token via OAuth flow


What Gets Synced

  • Email subject, body, and headers

  • Sender and recipient information

  • Timestamps and labels

  • Attachments (if enabled)

  • Thread relationships


Filtering Examples

By sender:

filter: "from:[email protected]"

By date range:

filter: "after:2024/01/01 before:2024/12/31"

With attachments:

filter: "has:attachment"

By label:

filter: "label:important"

Last updated

Was this helpful?