Gmail

Gmail logo

Gmail

Configuration

Gmail source connector integrates with the Gmail API to extract and synchronize email data.

Connects to your Gmail account.

It supports syncing email threads, individual messages, and file attachments.

Authentication

This connector uses OAuth 2.0 with custom credentials. You need to provide your OAuth application’s Client ID and Client Secret, then complete the OAuth consent flow.

OAuth Setup Required
  1. Create an OAuth application in your provider’s developer console
  2. Enter your Client ID and Client Secret when configuring the connection
  3. Complete the OAuth consent flow

Configuration Options

The following configuration options are available for this connector:

Configuration Parameters

Gmail configuration schema.

after_date
Optional[str]Required

Sync emails after this date (format: YYYY/MM/DD or YYYY-MM-DD).

included_labels
list[str]Defaults to []

Labels to include (e.g., ‘inbox’, ‘sent’, ‘important’). Defaults to inbox and sent.

excluded_labels
list[str]Defaults to []

Labels to exclude (e.g., ‘spam’, ‘trash’, ‘promotions’, ‘social’). Defaults to spam and trash.

excluded_categories
list[str]Defaults to []

Gmail categories to exclude (e.g., ‘promotions’, ‘social’, ‘updates’, ‘forums’).

gmail_query
Optional[str]Required

Advanced. Custom Gmail query string (overrides all other filters if provided).

Data Models

The following data models are available for this connector:

Schema for Gmail thread entities.

Reference: https://developers.google.com/gmail/api/reference/rest/v1/users.threads

FieldTypeDescription
thread_keystrStable Airweave thread key (thread_<gmail_id>)
gmail_thread_idstrNative Gmail thread ID
titlestrDisplay title derived from snippet
last_message_atOptional[datetime]Timestamp of the most recent message in the thread
snippetOptional[str]A short snippet from the thread
history_idOptional[str]The thread’s history ID
message_countOptional[int]Number of messages in the thread
label_idsList[str]Labels applied to this thread

Schema for Gmail message entities.

Reference: https://developers.google.com/gmail/api/reference/rest/v1/users.messages

FieldTypeDescription
message_keystrStable Airweave message key (msg_<gmail_id>)
message_idstrNative Gmail message ID
subjectstrSubject line (fallback applied if missing)
sent_atdatetimeTimestamp from the Date header (or internal date fallback)
internal_timestampdatetimeGmail internal timestamp representing last modification
thread_idstrID of the thread this message belongs to
senderOptional[str]Email address of the sender
toList[str]Recipients of the message
ccList[str]CC recipients
bccList[str]BCC recipients
dateOptional[datetime]Date the message was sent
snippetOptional[str]Brief snippet of the message content
label_idsList[str]Labels applied to this message
internal_dateOptional[datetime]Internal Gmail timestamp
web_url_valueOptional[str]Direct Gmail URL for the message

Schema for Gmail attachment entities.

Reference: https://developers.google.com/gmail/api/reference/rest/v1/users.messages.attachments

FieldTypeDescription
attachment_keystrStable Airweave attachment key (attach_<message>_<filename>)
filenamestrAttachment filename
message_idstrID of the message this attachment belongs to
attachment_idstrGmail’s attachment ID
thread_idstrID of the thread containing the message
web_url_valueOptional[str]URL to view the parent message in Gmail

Deletion signal for a Gmail message.

Emitted when the Gmail History API reports a messageDeleted. The entity_id matches the message entity’s ID format (msg_{message_id}) so downstream deletion removes the correct parent/children.

FieldTypeDescription
message_keystrStable Airweave message key (msg_<gmail_id>)
labelstrHuman-readable deletion label
message_idstrThe Gmail message ID that was deleted
thread_idOptional[str]Thread ID (optional if not provided by change record)

Integrate Airweave with Google APIs on localhost

This guide will walk you through connecting Google Workspace APIs to Airweave when running locally. Google provides extensive documentation on setting up your workspace. Below is a streamlined process for connecting Google APIs to Airweave.

  1. Create a Google Cloud project for your Google Workspace (if you don’t already have one)
  2. Enable the Google Workspace APIs for Gmail, Google Calendar, and Google Drive
  3. Configure Google OAuth 2.0 consent screen
  4. Under Audience, select Make external and add test users
  5. Under Data Access, add the following scopes:
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/drive.photos.readonly
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive.metadata
https://www.googleapis.com/auth/drive.metadata.readonly
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/calendar.events.public.readonly
https://www.googleapis.com/auth/calendar.freebusy
https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/auth/calendar.calendars.readonly
https://www.googleapis.com/auth/calendar.events.owned.readonly
https://www.googleapis.com/auth/calendar.events.readonly
  1. Create OAuth client ID credentials

  2. Under “Authorized redirect URIs,” click ”+ Add URI” and add the Redirect URI. Use the appropriate URL for your environment:

    Production (Airweave Cloud):

    https://api.airweave.ai/source-connections/callback

    Local:

    http://localhost:8001/source-connections/callback
  3. Locate the client ID and client secret from your newly created OAuth client. Add these credentials to the dev.integrations.yml file to enable Google API integration.