Google Gmail
Overview
The Google Gmail connector enables your Leena AI Agents to integrate with your organization's Gmail platform, facilitating automated email management, message operations, and workflow automation.
Google Gmail is Google's email service that allows users to send, receive, and manage email messages. The Google Gmail connector allows Leena AI to automate email workflows, manage messages, and interact with Gmail seamlessly.
API Details
Leena AI integrates with Google Gmail via REST APIs.
Documentation link: https://developers.google.com/gmail/api/guides
Setup
The Google Gmail connector uses OAuth 2.0 authentication with the authorization code grant type.
Prerequisites
Before setting up the Google Gmail connector, ensure you have:
- Administrator access to your Google Cloud Console
- Access to Google Cloud Console API & Services
- Ability to create OAuth applications in Google Cloud
- Access to your Leena AI workspace with connector management permissions
Get credentials
Here is how to create an OAuth client in Google Cloud Console:
- Log in to Google Cloud Console (Ensure you're signed in as an admin)
- Navigate to API & Services:
- Click on API & Services in the sidebar
- Select Credentials
- Enable Gmail API:
- Go to API & Services > Library
- Search for "Gmail API"
- Click Enable
- Create OAuth Client:
- Navigate back to Credentials
- Click + CREATE CREDENTIALS
- Select OAuth client ID
- Configure OAuth Client Details
- Application Type: Choose the type of application
- Name: Enter a descriptive name for your application
- Authorized JavaScript origins: Add your Leena AI domain
- Authorized redirect URIs: This will be filled later from Leena AI
- Save and Note Credentials (These credentials are displayed only once during creation)
Add connection
Here is how to add a connection on Leena AI:
- Log in to your Leena AI workspace
- Navigate to Settings > Integrations
- Search for "Google Gmail" and select it from the list to add its new connector
- Start configuring the connector
- Client ID: OAuth application client ID
- Client Secret: OAuth application client secret
- Scope: List of permissions required to perform actions through Leena AI (Pre-filled with Gmail permissions)
- Grant Type: Authorization grant type for OAuth 2.0 (Pre-filled as 'authorization_code')
- ID Mapping Fields: The profile field in Leena AI, which corresponds to unique identifier in Gmail (Pre-filled with 'email')
- Redirect URL: The callback URL for OAuth flow (Auto-generated by Leena AI)
- Complete OAuth Flow and Save Configurations
- Click Connect in Leena AI for Google Gmail connector setup
- You'll be redirected to Google authorization page
- Sign in to your Google account if prompted
- Click Allow to grant permissions for Gmail access
- You'll be redirected back to Leena AI with a successful connection
- The connector will be saved
- Copy Callback URL and Update Google Cloud OAuth Client
- Once the connector is saved in Leena AI, you can reopen the connector to view the Callback URL
- Copy the Callback URL from Leena AI
- Go back to Google Cloud Console > API & Services > Credentials
- Edit your OAuth client and add the Callback URL to Authorized redirect URIs
- Save the changes
Actions
The following actions are supported for the Google Gmail connector:
Send Email
Sends an email message from the authenticated user's Gmail account. The Agent can leverage the skill (workflow), which has been designed to send a new email through Gmail, once the user provides the email details.
Input Parameters
Here are the input parameters required to set up this action:
Mandatory
| Name | Description |
|---|---|
| To | Recipient email addresses |
| Subject | Email subject line |
| Body | Email body content (plain text) |
Optional
Name | Description |
|---|---|
CC | Carbon copy recipients |
BCC | Blind carbon copy recipients |
Attachments | Array of file attachments; each attachment includes:
|
Here is a sample JSON input:
{
"to": [
{"email": "[email protected]"},
{"email": "[email protected]"}
],
"subject": "Meeting Notes",
"body": "This is the email body content.",
"cc": [{"email": "[email protected]"}],
"bcc": [{"email": "[email protected]"}],
"attachments": [
{
"filename": "document.pdf",
"mimeType": "application/pdf",
"fileData": "base64_encoded_data_or_url"
}
]
}Response
Upon successful sending, the action returns the sent email details including:
- Message ID
- Thread ID
- Success confirmation message
List All Emails
Retrieves a list of emails from a Gmail account with advanced filtering capabilities. This action can be leveraged by Leena AI Orchestrator/Agent to list emails based on various criteria. Here are some common use cases:
-
Daily Schedule: Get all emails for today
-
Message Search: Find emails by sender, subject, or content
-
Unread Messages: Check for unread emails
-
Filtered Retrieval: Get emails within a date range or with attachments
Input Parameters
Here are the input parameters required to set up this action:
Optional
Name | Description |
|---|---|
Page Size | Number of emails to return per page (1-500, default: 10) |
Page Token | Pagination token for next/previous page |
Query | Gmail search query (supports Gmail syntax) |
Message Filter | Filter by read status, options:
|
Here is a sample JSON input:
{
"pageSize": 20,
"query": "from:[email protected] subject:report has:attachment",
"filter": "unread"
}Response
The action returns a list of email messages, each containing:
- Message ID
- Thread ID
- Label IDs
- Snippet (preview text)
- From, To, Subject, Date
- CC, BCC, Reply-To
- Email body (plain text and HTML)
- Attachments information
- Read/Starred/Important status flags
- Next page token for pagination
Read Email
Retrieves complete email details for a specific message. The Agent can leverage the skill (workflow), which has been designed to read detailed information from a Gmail message, once the user provides the message ID. Here are some common use cases:
-
Email Processing: Extract email content for automation workflows
-
Attachment Management: Identify and process email attachments
-
Support Ticket Integration: Convert emails to support tickets
-
Compliance: Retrieve complete email records for archival
Input Parameters
Here are the input parameters required to set up this action:
Mandatory
| Name | Description |
|---|---|
| Message ID | The unique identifier of the Gmail message to retrieve |
Here is a sample JSON input:
{
"messageId": "18c1a2b3d4e5f6g7"
}Response
Upon successful retrieval, the action returns the complete email details including:
- Message ID and Thread ID
- All email headers (From, To, Subject, Date, CC, BCC, Reply-To)
- Email body in both plain text and HTML formats
- Attachments metadata (filename, MIME type, size, attachment ID)
- Email status flags (read, starred, important, draft, trash, spam)
- Content type information
Download Attachment
Downloads email attachments from Gmail messages. The Agent can leverage the skill (workflow), which has been designed to retrieve attachment files from Gmail messages, once the user provides the message and attachment identifiers. Here are some common use cases:
-
Document Processing: Download and process attached documents
-
File Management: Save email attachments to storage systems
-
Automated Workflows: Extract and process invoice PDFs, reports, or other files
-
Backup Operations: Archive important email attachments
Input Parameters
Here are the input parameters required to set up this action:
Mandatory
| Name | Description |
|---|---|
| Message ID | The Gmail message ID containing the attachment |
| Attachment ID | The unique identifier of the attachment to download |
Here is a sample JSON input:
{
"messageId": "18c1a2b3d4e5f6g7",
"attachmentId": "ANGjdJ9vHFCmXEkYY8Xxxx"
}Response
Upon successful download, the action returns the attachment data including:
- Message ID
- Attachment ID
- Size in bytes
- Base64-encoded attachment content (ready for decoding and saving)
Updated about 19 hours ago
