How to Automate Gmail with OpenClaw: Full Setup Guide
OpenClaw can connect directly to your Gmail account to triage incoming messages, draft replies, summarize threads, and route emails to the right place. This guide walks through every step, from enabling the Gmail API to creating your first email skill and testing it on real messages.
Why Automate Gmail with OpenClaw?
Most people juggle six or more apps to manage email. OpenClawβs digital twin approach collapses all of that into a single local AI agent. Your email data stays on your machine.
What Can It Do?
- Email triage: Categorize incoming messages by urgency, topic, or sender
- Auto-reply drafts: Generate drafts that match your writing style
- Daily digest: Morning summary grouped by priority and topic
- Label and archive: Apply Gmail labels based on content
- Meeting extraction: Pull dates, times, and attendees from threads
Prerequisites
- OpenClaw installed and running
- A Gmail account (personal or Google Workspace)
- Node 22.16+ or Node 24
- A Google Cloud project (free tier is enough)
Step 1: Enable the Gmail API
Go to the Google Cloud Console, enable the Gmail API, create OAuth 2.0 credentials (Desktop app type), and download credentials.json.
Step 2: Configure OpenClaw for Gmail
Option A: Gmail API (recommended)
openclaw config set gmail.auth_method api openclaw config set gmail.credentials_path /path/to/credentials.json openclaw config set gmail.scopes "gmail.readonly,gmail.modify,gmail.labels" openclaw config set gmail.token_path ~/.openclaw/gmail-token.json
Option B: IMAP
openclaw config set gmail.auth_method imap openclaw config set gmail.imap_host imap.gmail.com openclaw config set gmail.imap_port 993 openclaw config set gmail.smtp_host smtp.gmail.com openclaw config set gmail.smtp_port 587 openclaw config set gmail.username your-email@gmail.com openclaw config set gmail.app_password your-app-password
Optional: Real-Time Processing with Pub/Sub
openclaw config set gmail.pubsub_enabled true openclaw config set gmail.pubsub_topic "projects/your-project/topics/gmail-notifications" openclaw config set gmail.pubsub_subscription "projects/your-project/subscriptions/gmail-sub"
Step 3: Create Your First Email Skill
openclaw skill create email-triage \ --trigger "new_email" \ --action "classify" \ --labels "urgent,action-required,fyi,low-priority" \ --prompt "Read the subject and body. Classify by urgency."
Step 4: Test with Real Emails
openclaw skill test email-triage --dry-run --limit 10
Step 5: Monitor and Adjust
openclaw dashboard openclaw skill logs email-triage --last 20
Security Considerations
- Use OAuth with minimal scopes
- Store credentials in
~/.openclaw/ - Review the OpenClaw security checklist
- Use App Passwords for IMAP
Get guides like this in your inbox every Wednesday.
No spam. Unsubscribe anytime.
You'll probably need this again.
Press Cmd+D (Mac) or Ctrl+D (Windows) to bookmark this page.
Need help with your OpenClaw setup?
We do remote setup, troubleshooting, and training worldwide.
Book a Call