← All guides
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
Need OpenClaw fixed live?
Remote rescue sessions for gateway, auth, tunnel, VPS, and model access problems.
See Rescue SessionRead next
How to Connect OpenClaw to Home Assistant: Smart Home Control with AI
Connect OpenClaw to Home Assistant and control lights, locks, thermostats, and automations with natural language. Full setup guide with example commands.
What Is OpenClaw? A Plain-English Guide to the AI Agent Everyone's Talking About
OpenClaw is a free, open-source AI agent that runs on your computer and automates real tasks like email, research, and file management. Here's how it works.
Can OpenClaw Replace Your Virtual Assistant? A Freelancer's Guide
OpenClaw handles email triage, invoicing, scheduling, and client follow-ups for freelancers at a fraction of virtual assistant costs. Full workflow guide.
10 Things People Actually Built With OpenClaw (Not Hype, Real Results)
10 real OpenClaw use cases from Reddit and Twitter. Expense tracking, multi-agent teams, family calendars, marketing bots, and more.