🦞OpenClaw Guide
Email

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:

1. Gmail Pub/Sub Setup — Complex but official, requires Google Cloud 2. Custom Skills with gogcli — Scripts that call Google APIs via CLI 3. Browser Automation — Using unbrowse to control Gmail in a browser 4. 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 - gogcli tool installed - Tailscale (or other method) for public webhook endpoint

### Step 1: Install gogcli

bash
# Install the Google CLI toolnpm install -g gogcli# orbrew install gogcli

### Step 2: Authorize with Gmail

bash
# This opens a browser for OAuth consentgogcli auth login --scopes gmail.readonly,gmail.send,gmail.compose

Important: Make sure you authorize with the correct scopes. Missing scopes = missing functionality.

### Step 3: Set up the webhook endpoint

bash
# If using Tailscale Funnel for public endpointtailscale funnel 8080# Configure OpenClaw to receive Gmail webhooksopenclaw hooks gmail setup

### Step 4: Test the integration

bash
# Verify gogcli can access Gmailgogcli gmail list --limit 5# Check webhook statusopenclaw hooks gmail status

---

## Option 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

bash
# Check if sandbox is enabledopenclaw config get sandbox.enabled# View sandbox settingsopenclaw config list | grep sandbox

### Fix 2: Allowlist Your Script

If you trust the script, add it to the sandbox allowlist:

bash
# Add script to allowed executablesopenclaw config set sandbox.allowlist.scripts "/path/to/your/calendar-script.sh"

### Fix 3: Run Script Manually First

bash
# 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

bash
# Check current auth statusgogcli auth status# If expired, re-authorize with correct scopesgogcli auth login --scopes gmail.readonly,gmail.send,gmail.compose,gmail.modify

### Step 2: Check the correct account

bash
# See which account gogcli is usinggogcli auth whoami# If wrong account, logout and re-authgogcli auth logoutgogcli auth login

### Step 3: Test draft creation directly

bash
# 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 5

### Step 4: Check logs for errors

bash
# 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:

bash
# 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

bash
# 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: ``bash echo '{"message": "Process this"}' > ~/.openclaw/inbox/email-001.json

🔥 Your AI should run your business, not just answer questions.

We'll show you how.$97/mo (going to $197 soon)

Join Vibe Combinator →

📋 Quick Commands

CommandDescription
gogcli auth login --scopes gmail.readonly,gmail.send,gmail.composeAuthorize gogcli with Gmail API scopes
gogcli auth statusCheck current gogcli authorization status
gogcli auth whoamiSee which Google account gogcli is using
gogcli gmail list --limit 5Test Gmail access by listing recent emails
gogcli gmail drafts list --limit 5List recent Gmail drafts to verify they're being created
openclaw hooks gmail setupSet up Gmail Pub/Sub webhook integration
openclaw hooks gmail statusCheck Gmail webhook integration status
openclaw config get sandbox.enabledCheck if sandbox mode is blocking script execution
tailscale funnel 8080Expose local port for Gmail webhook (requires Tailscale)
openclaw logs --tail 100 | grep -i gmailView Gmail-related logs for troubleshooting

Related Issues

    🐙 Your AI should run your business.

    Weekly live builds + template vault. We'll show you how to make AI actually work.$97/mo (going to $197 soon)

    Join Vibe Combinator →

    Still stuck?

    Join our Discord community for real-time help.

    Join Discord