How to Connect Gmail to OpenClaw
A complete guide to integrating Gmail with OpenClaw using ClawLink. Send emails, read messages, and manage your inbox with your AI agent.What You Can Do
Once connected, your OpenClaw agent can:- Send emails - Compose and send new emails
- Read emails - Fetch recent messages from your inbox
- Create drafts - Save drafts for review
- Manage labels - Organize emails with labels
- Search emails - Find specific messages
Prerequisites
Before connecting Gmail, you’ll need:- A Google account (Gmail or Google Workspace)
- Access to Google Cloud Console (for OAuth setup)
Step 1: Set Up Google Cloud Project
- Go to console.cloud.google.com
- Click Select a project → New Project
- Name it “ClawLink” and create
Step 2: Enable Gmail API
- Go to APIs & Services → Library
- Search for “Gmail API”
- Click Enable
Step 3: Configure OAuth Consent
- Go to APIs & Services → OAuth consent screen
- Choose External
- Fill in required fields:
- App name: “ClawLink”
- Email: your email
- Click Save and continue
- Add these scopes:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.modify
- Add your email as a test user
Step 4: Create Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Application type: Desktop application
- Click Create
- Download the JSON file
Step 5: Connect to ClawLink
- Go to your ClawLink dashboard
- Navigate to Integrations
- Find Gmail and click Connect
- Enter your OAuth credentials:
- Client ID
- Client Secret
- Run the OAuth flow to get refresh token
- Click Save
Example Usage
Here are common prompts for Gmail:Send an Email
“Send an email to [email protected] with subject ‘Project Update’ and body ‘Here’s the latest progress on our project.’”
Read Recent Emails
“Show me the last 5 unread emails in my inbox.”
Find Specific Email
“Find emails from [email protected] from the last week.”
API Reference
| Function | Description |
|---|---|
gmail_send_email | Send a new email |
gmail_read_emails | Read emails from inbox |
gmail_create_draft | Create an email draft |
gmail_modify_labels | Add/remove labels from emails |
Troubleshooting
”OAuth error”
- Make sure you added test users in OAuth consent
- Verify all scopes are selected
”Token expired”
- Run the OAuth flow again to refresh
- Generate a new refresh token
”Permission denied”
- Check Gmail API is enabled
- Verify scopes match your needs
Security
- Credentials encrypted at rest
- Only decrypted at request time
- OAuth tokens auto-refresh
