Gmail

Gmail logo

Gmail

Connect your Gmail data to Airweave

Overview

The Gmail connector allows you to sync data from Gmail into Airweave, making it available for search and retrieval by your agents.

Configuration

GmailSource

Gmail source implementation (read-only).

Retrieves and yields Gmail objects (labels, threads, messages, drafts) as entity schemas defined in entities/gmail.py.

Authentication

This connector uses OAuth 2.0 with refresh token.

You can connect through the Airweave UI, which will guide you through the OAuth flow.

Entities

The following data models are available for this connector:

Schema for Gmail label entities.

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

FieldTypeDescription
namestrThe display name of the label
label_typestrType of label: ‘system’ or ‘user’
message_list_visibilityOptional[str]Show/hide in message list
label_list_visibilityOptional[str]Show/hide in label list
total_messagesOptional[int]Total number of messages with this label
unread_messagesOptional[int]Number of unread messages with this label

Schema for Gmail thread entities.

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

FieldTypeDescription
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
last_message_dateOptional[datetime]Date of the last message

Schema for Gmail message entities.

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

FieldTypeDescription
thread_idstrID of the thread this message belongs to
subjectOptional[str]Subject line of the message
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
body_plainOptional[str]Plain text message body
body_htmlOptional[str]HTML message body
label_idsList[str]Labels applied to this message
internal_dateOptional[datetime]Internal Gmail timestamp
size_estimateOptional[int]Estimated size in bytes

Schema for Gmail draft entities.

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

FieldTypeDescription
message_idOptional[str]ID of the draft message
thread_idOptional[str]ID of the thread if part of one
subjectOptional[str]Subject line of the draft
toList[str]Intended recipients
ccList[str]Intended CC recipients
bccList[str]Intended BCC recipients
body_plainOptional[str]Plain text draft content
body_htmlOptional[str]HTML draft content
created_dateOptional[datetime]Date the draft was created
updated_dateOptional[datetime]Date the draft was last updated

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 following URIs:
    http://localhost:8080/auth/callback/gmail
    http://localhost:8080/auth/callback/google_calendar
    http://localhost:8080/auth/callback/google_drive
  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.