Email & Gmail Integration — Setup Guide
How to integrate Gmail and email with OpenClaw using the Gmail Pub/Sub system, gogcli tool, and custom skills. Includes troubleshooting for drafts not appearing and script execution issues.
⚠️ The Problem
Users expect simple 'connect your Google account' functionality but encounter: (1) No built-in Google OAuth integration — Gmail requires complex Pub/Sub setup, (2) Gmail drafts not appearing after bot creates them, (3) Custom scripts for Google Calendar suddenly stop working with errors like 'doesn't have the capability to run local scripts', and (4) Confusion about how to programmatically send data to OpenClaw.
🔍 Why This Happens
No Simple Google Integration: OpenClaw intentionally does NOT have a simple 'Connect Google Account' button. Google's OAuth requirements for Gmail and Calendar access are extremely strict — they require security audits, privacy policies, and app verification. Instead, OpenClaw provides tools for power users to set up their own integrations.
Gmail Pub/Sub Complexity: The Gmail integration uses Google Cloud Pub/Sub which requires: (1) A Google Cloud project with billing enabled, (2) Pub/Sub API enabled, (3) The gogcli tool installed and authorized, (4) A public endpoint (via Tailscale or similar) for webhooks, and (5) Manual CLI setup.
Drafts Not Appearing: Common causes include: incorrect Gmail API scopes during authorization, rate limiting, or the draft being created in a different account than expected. The gogcli tool may also have stale OAuth tokens.
Scripts Stopped Working: When OpenClaw's sandbox mode is enabled (Docker-based or security policy), it blocks system.run commands by default. Scripts that worked before sandboxing was enabled will fail with permission errors. This is a security feature, not a bug.
✅ The Fix
Understanding Gmail Integration Options
There's no simple 'Connect Google Account' button in OpenClaw. Users who claim to have Google integration are using one of these approaches:
- Gmail Pub/Sub Setup — Complex but official, requires Google Cloud
- Custom Skills with gogcli — Scripts that call Google APIs via CLI
- Browser Automation — Using unbrowse to control Gmail in a browser
- IMAP/SMTP — Traditional email protocols (simpler but less features)
Option 1: Gmail Pub/Sub Integration (Advanced)
This is the 'official' way documented in docs/automation/gmail-pubsub.md.
Prerequisites
- Google Cloud project with billing enabled
- Pub/Sub API enabled in your project
gogclitool installed- Tailscale (or other method) for public webhook endpoint
Step 1: Install gogcli
# Install the Google CLI toolnpm install -g gogcli# orbrew install gogcliStep 2: Authorize with Gmail
# This opens a browser for OAuth consentgogcli auth login --scopes gmail.readonly,gmail.send,gmail.composeImportant: Make sure you authorize with the correct scopes. Missing scopes = missing functionality.
Step 3: Set up the webhook endpoint
# If using Tailscale Funnel for public endpointtailscale funnel 8080# Configure OpenClaw to receive Gmail webhooksopenclaw hooks gmail setupStep 4: Test the integration
# Verify gogcli can access Gmailgogcli gmail list --limit 5# Check webhook statusopenclaw hooks gmail statusOption 2: Custom Skills for Google Calendar
Users have created skills that generate scripts for Google Calendar events.
If Your Script Stopped Working
Error: "doesn't have the capability to run local scripts"
Cause: Sandbox mode is blocking system.run
Fix 1: Check Sandbox Status
# Check if sandbox is enabledopenclaw config get sandbox.enabled# View sandbox settingsopenclaw config list | grep sandboxFix 2: Allowlist Your Script
If you trust the script, add it to the sandbox allowlist:
# Add script to allowed executablesopenclaw config set sandbox.allowlist.scripts "/path/to/your/calendar-script.sh"Fix 3: Run Script Manually First
# Make script executablechmod +x ~/clawd/skills/google-calendar/create-event.sh# Test it directly~/clawd/skills/google-calendar/create-event.sh "Meeting" "2024-01-15 10:00" "2024-01-15 11:00"Troubleshooting: Drafts Not Appearing in Gmail
Step 1: Verify gogcli authorization
# Check current auth statusgogcli auth status# If expired, re-authorize with correct scopesgogcli auth login --scopes gmail.readonly,gmail.send,gmail.compose,gmail.modifyStep 2: Check the correct account
# See which account gogcli is usinggogcli auth whoami# If wrong account, logout and re-authgogcli auth logoutgogcli auth loginStep 3: Test draft creation directly
# Try creating a draft via CLIgogcli gmail draft create --to "test@example.com" --subject "Test" --body "Testing draft creation"# List recent draftsgogcli gmail drafts list --limit 5Step 4: Check logs for errors
# View OpenClaw logs for Gmail-related errorsopenclaw logs --tail 100 | grep -i "gmail\|draft\|gog"Option 3: Browser Automation for Gmail
If the API setup is too complex, use browser automation:
# Capture Gmail's internal APIopenclaw unbrowse capture --url "https://mail.google.com"# Or use the browser agentopenclaw unbrowse browse --url "https://mail.google.com" --task "compose email to test@example.com"Sending Custom Data to OpenClaw Programmatically
To send messages, emails, or custom data streams to OpenClaw:
Method 1: Webhooks
# Send data via webhookcurl -X POST http://localhost:8080/webhook/custom \ -H "Content-Type: application/json" \ -d '{"type": "email", "from": "user@example.com", "body": "Hello"}'Method 2: Custom Channel Plugin
Create a custom channel in ~/.openclaw/channels/ that receives your data stream.
Method 3: File-Based Ingestion
Write data to a watched directory that OpenClaw monitors:
echo '{"message": "Process this"}' > ~/.openclaw/inbox/email-001.json🔥 Your AI should run your business, not just answer questions.
We'll show you how.Free to join.
📋 Quick Commands
| Command | Description |
|---|---|
| gogcli auth login --scopes gmail.readonly,gmail.send,gmail.compose | Authorize gogcli with Gmail API scopes |
| gogcli auth status | Check current gogcli authorization status |
| gogcli auth whoami | See which Google account gogcli is using |
| gogcli gmail list --limit 5 | Test Gmail access by listing recent emails |
| gogcli gmail drafts list --limit 5 | List recent Gmail drafts to verify they're being created |
| openclaw hooks gmail setup | Set up Gmail Pub/Sub webhook integration |
| openclaw hooks gmail status | Check Gmail webhook integration status |
| openclaw config get sandbox.enabled | Check if sandbox mode is blocking script execution |
| tailscale funnel 8080 | Expose local port for Gmail webhook (requires Tailscale) |
| openclaw logs --tail 100 | grep -i gmail | View Gmail-related logs for troubleshooting |
Related Issues
📚 You Might Also Like
Set Up AI Email Assistant
Gmail Integration
50 Things to Do With OpenClaw After Setup
The difference between OpenClaw-as-chatbot and OpenClaw-as-actual-assistant is integrations and automation. Here are 50 real use cases across email, calendar, research, writing, dev, finance, and personal productivity.
Google Workspace
Full integration with Gmail, Google Calendar, Drive, Docs, Sheets, and Contacts. Manage your digital life through conversation.
🐙 Your AI should run your business.
Weekly live builds + template vault. We'll show you how to make AI actually work.Free to join.
Join Vibe Combinator →