Gmail Pub/Sub integration requires a persistent local process to receive push notifications. This is not directly available in ClawCentral's serverless managed platform. As an alternative, consider using scheduled cron jobs to poll Gmail via the API (configured via Admin UI → Settings → Cron), or triggering the agent via other channels.
Gmail Pub/Sub -> OpenClaw
Goal: Gmail watch -> Pub/Sub push -> gog gmail watch serve -> OpenClaw webhook.
Prereqs
gcloudinstalled and logged in (install guide).gog(gogcli) installed and authorized for the Gmail account (gogcli.sh).- OpenClaw hooks enabled (see Webhooks).
tailscalelogged in (tailscale.com). Supported setup uses Tailscale Funnel for the public HTTPS endpoint. Other tunnel services can work, but are DIY/unsupported and require manual wiring. Right now, Tailscale is what we support.
Example hook config (enable Gmail preset mapping):
{
hooks: {
enabled: true,
token: "OPENCLAW_HOOK_TOKEN",
path: "/hooks",
presets: ["gmail"],
},
}
To deliver the Gmail summary to a chat surface, override the preset with a mapping
that sets deliver + optional channel/to:
{
hooks: {
enabled: true,
token: "OPENCLAW_HOOK_TOKEN",
presets: ["gmail"],
mappings: [
{
match: { path: "gmail" },
action: "agent",
wakeMode: "now",
name: "Gmail",
sessionKey: "hook:gmail:{{messages[0].id}}",
messageTemplate: "New email from {{messages[0].from}}\nSubject: {{messages[0].subject}}\n{{messages[0].snippet}}\n{{messages[0].body}}",
model: "openai/gpt-5.2-mini",
deliver: true,
channel: "last",
// to: "+15551234567"
},
],
},
}
If you want a fixed channel, set channel + to. Otherwise channel: "last"
uses the last delivery route (falls back to WhatsApp).
To force a cheaper model for Gmail runs, set model in the mapping
(provider/model or alias). If you enforce agents.defaults.models, include it there.
To set a default model and thinking level specifically for Gmail hooks, add
hooks.gmail.model / hooks.gmail.thinking in your config:
{
hooks: {
gmail: {
model: "openrouter/meta-llama/llama-3.3-70b-instruct:free",
thinking: "off",
},
},
}
Notes:
- Per-hook
model/thinkingin the mapping still overrides these defaults. - Fallback order:
hooks.gmail.model→agents.defaults.model.fallbacks→ primary (auth/rate-limit/timeouts). - If
agents.defaults.modelsis set, the Gmail model must be in the allowlist. - Gmail hook content is wrapped with external-content safety boundaries by default.
To disable (dangerous), set
hooks.gmail.allowUnsafeExternalContent: true.
To customize payload handling further, add hooks.mappings or a JS/TS transform module
under ~/.openclaw/hooks/transforms (see Webhooks).
Wizard (recommended)
Use the OpenClaw helper to wire everything together (installs deps on macOS via brew):
openclaw webhooks gmail setup \
--account openclaw@gmail.com
Defaults:
- Uses Tailscale Funnel for the public push endpoint.
- Writes
hooks.gmailconfig foropenclaw webhooks gmail run. - Enables the Gmail hook preset (
hooks.presets: ["gmail"]).
Path note: when tailscale.mode is enabled, OpenClaw automatically sets
hooks.gmail.serve.path to / and keeps the public path at
hooks.gmail.tailscale.path (default /gmail-pubsub) because Tailscale
strips the set-path prefix before proxying.
If you need the backend to receive the prefixed path, set
hooks.gmail.tailscale.target (or --tailscale-target) to a full URL like
http://127.0.0.1:8788/gmail-pubsub and match hooks.gmail.serve.path.
Want a custom endpoint? Use --push-endpoint <url> or --tailscale off.
Platform note: on macOS the wizard installs gcloud, gogcli, and tailscale
via Homebrew; on Linux install them manually first.
Gateway auto-start (recommended):
- When
hooks.enabled=trueandhooks.gmail.accountis set, the Gateway startsgog gmail watch serveon boot and auto-renews the watch. - Set
OPENCLAW_SKIP_GMAIL_WATCHER=1to opt out (useful if you run the daemon yourself). - Do not run the manual daemon at the same time, or you will hit
listen tcp 127.0.0.1:8788: bind: address already in use.
Manual daemon (starts gog gmail watch serve + auto-renew):
openclaw webhooks gmail run
One-time setup
- Select the GCP project that owns the OAuth client used by
gog.
gcloud auth login
gcloud config set project <project-id>
Note: Gmail watch requires the Pub/Sub topic to live in the same project as the OAuth client.
- Enable APIs:
gcloud services enable gmail.googleapis.com pubsub.googleapis.com
- Create a topic:
gcloud pubsub topics create gog-gmail-watch
- Allow Gmail push to publish:
gcloud pubsub topics add-iam-policy-binding gog-gmail-watch \
--member=serviceAccount:gmail-api-push@system.gserviceaccount.com \
--role=roles/pubsub.publisher
Start the watch
gog gmail watch start \
--account openclaw@gmail.com \
--label INBOX \
--topic projects/<project-id>/topics/gog-gmail-watch
Save the history_id from the output (for debugging).