gmail
Send, read, search, and manage Gmail emails via the Gmail REST API. Use when asked to send an email, check inbox, read messages, search mail, reply to emails, draft emails, or manage labels. Triggers on phrases like 'send an email', 'check my email', 'reply to', 'draft a message', 'search my inbox', 'read my latest emails', 'send a gmail'.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/cehd5170/gmail-checkerGmail Skill
Send, read, search, reply, and manage Gmail directly from OpenClaw.
Setup
Option 1: OAuth2 Access Token (recommended)
- Create OAuth2 credentials at https://console.cloud.google.com/apis/credentials
- Enable the Gmail API at https://console.cloud.google.com/apis/library/gmail.googleapis.com
- Obtain an access token via OAuth2 flow with scopes:
https://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.modify
- Set the environment variable:
export GMAIL_ACCESS_TOKEN="your-access-token"
Option 2: Refresh Token (long-lived)
If you have a refresh token, set these additional variables:
export GMAIL_CLIENT_ID="your-client-id"
export GMAIL_CLIENT_SECRET="your-client-secret"
export GMAIL_REFRESH_TOKEN="your-refresh-token"
All API calls use Bearer auth:
curl -s -H "Authorization: Bearer $GMAIL_ACCESS_TOKEN" \
"https://gmail.googleapis.com/gmail/v1/users/me/..."
Token Refresh
If GMAIL_REFRESH_TOKEN is set, refresh the access token before any API call:
GMAIL_ACCESS_TOKEN=$(curl -s -X POST "https://oauth2.googleapis.com/token" \
-d "client_id=$GMAIL_CLIENT_ID" \
-d "client_secret=$GMAIL_CLIENT_SECRET" \
-d "refresh_token=$GMAIL_REFRESH_TOKEN" \
-d "grant_type=refresh_token" | jq -r '.access_token')
Commands
Send an Email
Parse the user's request for:
| Field | Required | Description |
|---|---|---|
| to | yes | Recipient email address(es), comma-separated |
| subject | yes | Email subject line |
| body | yes | Email body (plain text or HTML) |
| cc | no | CC recipients |
| bcc | no | BCC recipients |
| attachments | no | File paths to attach |
| research | no | Topic to web-search for enriching the email body |
Web Research (if applicable)
If the user wants research-informed content:
- Use
web_searchto find relevant information. - Fetch key pages with
xurlorcurlfor details. - Incorporate findings into the email body naturally.
Compose and Send
Build a raw RFC 2822 message and base64url-encode it:
# Build raw message
RAW_MESSAGE=$(cat <<'MSGEOF'
From: me
To: [email protected]
Subject: Email subject
Content-Type: text/html; charset="UTF-8"
MIME-Version: 1.0
<html><body>
<p>Email body here.</p>
</body></html>
MSGEOF
)
# Base64url encode (no padding, URL-safe)
ENCODED=$(echo -n "$RAW_MESSAGE" | base64 -w 0 | tr '+/' '-_' | tr -d '=')
# Send
curl -s -X POST \
-H "Authorization: Bearer $GMAIL_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
"https://gmail.googleapis.com/gmail/v1/users/me/messages/send" \
-d "{\"raw\": \"$ENCODED\"}"
Extract the message ID from the response and report success.
Read / Check Inbox
List recent messages:
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-cehd5170-gmail-checker": {
"enabled": true,
"auto_update": true
}
}
}