๐ŸงฉCustom Development

How to Connect OpenClaw to Gmail and Google Calendar

Intermediate1-3 hoursUpdated 2025-01-16

Connecting OpenClaw to Gmail and Google Calendar transforms your AI assistant into a powerful email and scheduling automation tool. This guide walks you through the complete setup: creating a Google Cloud project, configuring OAuth, enabling the necessary APIs, and setting up the OpenClaw Google adapter.

Why This Is Hard to Do Yourself

These are the common pitfalls that trip people up.

๐Ÿ”

OAuth consent screen complexity

Google's OAuth setup has multiple verification steps, scopes, and approval processes that are easy to misconfigure

๐Ÿ”‘

Credential management

Client IDs, client secrets, refresh tokens, and service account keys need to be stored securely and rotated properly

๐Ÿ“ง

Gmail API quotas and limits

Gmail API has rate limits, quota restrictions, and batching requirements that aren't obvious until you hit them

๐Ÿ“…

Calendar timezone handling

Calendar events have complex timezone logic. All-day events, recurring events, and timezone conversions require careful handling

Step-by-Step Guide

Step 1

Create a Google Cloud project

# 1. Go to https://console.cloud.google.com
# 2. Click "Select a project" โ†’ "New Project"
# 3. Name it "OpenClaw Integration"
# 4. Note your Project ID (you'll need it later)
Step 2

Enable Gmail and Calendar APIs

# In Google Cloud Console:
# 1. Navigate to "APIs & Services" โ†’ "Library"
# 2. Search for "Gmail API" and click "Enable"
# 3. Search for "Google Calendar API" and click "Enable"
# 4. Wait 2-3 minutes for APIs to fully activate
Step 3

Configure OAuth consent screen

# In "APIs & Services" โ†’ "OAuth consent screen":
# 1. Choose "External" user type (unless using Google Workspace)
# 2. Fill in:
#    - App name: OpenClaw
#    - User support email: your-email@example.com
#    - Developer contact: your-email@example.com
# 3. Add scopes:
#    - https://www.googleapis.com/auth/gmail.modify
#    - https://www.googleapis.com/auth/calendar.events
# 4. Add test users (your Gmail address)
# 5. Save and continue

Warning: Apps in "Testing" mode are limited to 100 users. For production use, you need to submit for Google verification, which can take weeks.

Step 4

Create OAuth credentials

# In "APIs & Services" โ†’ "Credentials":
# 1. Click "Create Credentials" โ†’ "OAuth client ID"
# 2. Application type: "Desktop app"
# 3. Name: "OpenClaw Desktop Client"
# 4. Click "Create"
# 5. Download the JSON file (credentials.json)
# 6. Save it to: ~/.openclaw/credentials/google-credentials.json
Step 5

Configure the OpenClaw Google adapter

# Create adapter config:
cat > ~/.openclaw/adapters/google/config.json << 'EOF'
{
  "enabled": true,
  "credentials_path": "~/.openclaw/credentials/google-credentials.json",
  "token_path": "~/.openclaw/credentials/google-token.json",
  "scopes": [
    "https://www.googleapis.com/auth/gmail.modify",
    "https://www.googleapis.com/auth/calendar.events"
  ],
  "auto_refresh": true
}
EOF

# Restart OpenClaw to load the adapter:
npm restart
Step 6

Authorize OpenClaw to access your Google account

# In OpenClaw chat, trigger OAuth flow:
/connect google

# OpenClaw will:
# 1. Open browser with Google OAuth consent screen
# 2. Ask you to sign in and grant permissions
# 3. Save the refresh token to google-token.json

# Verify connection:
/google test-connection

Warning: The OAuth flow generates a refresh token that never expires. Store google-token.json securely and never commit it to version control.

Step 7

Test Gmail and Calendar access

# Test Gmail reading:
/gmail list-messages limit:5

# Test Gmail sending:
/gmail send to:yourself@example.com subject:"Test" body:"Hello from OpenClaw"

# Test Calendar reading:
/calendar list-events days:7

# Test Calendar creation:
/calendar create-event title:"OpenClaw Test" start:"2025-02-01T14:00:00" duration:60

Google API Integration Done Right

OAuth flows, token refresh, rate limiting, and error handling โ€” Google API integrations have many moving parts. We build production-ready Gmail and Calendar integrations that handle edge cases and won't break.

Get matched with a specialist who can help.

Sign Up for Expert Help โ†’

Frequently Asked Questions