Gmail Pub/Sub -> Clawdbot
Goal: Gmail watch -> Pub/Sub push ->gog gmail watch serve -> Clawdbot webhook.
Prereqs
gcloudinstalled and logged in (install guide).gog(gogcli) installed and authorized for the Gmail account (gogcli.sh).- Clawdbot hooks enabled (see
docs/webhook.md). 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.
deliver + optional provider/to:
provider + to. Otherwise provider: "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 agent.models, include it there.
To customize payload handling further, add hooks.mappings or a JS/TS transform module
under hooks.transformsDir (see docs/webhook.md).
Wizard (recommended)
Use the Clawdbot helper to wire everything together (installs deps on macOS via brew):- Uses Tailscale Funnel for the public push endpoint.
- Writes
hooks.gmailconfig forclawdbot hooks gmail run. - Enables the Gmail hook preset (
hooks.presets: ["gmail"]).
tailscale.mode is enabled, Clawdbot 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.
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
CLAWDBOT_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.
gog gmail watch serve + auto-renew):
One-time setup
- Select the GCP project that owns the OAuth client used by
gog.
- Enable APIs:
- Create a topic:
- Allow Gmail push to publish:
Start the watch
history_id from the output (for debugging).
Run the push handler
Local example (shared token auth):--tokenprotects the push endpoint (x-gog-tokenor?token=).--hook-urlpoints to Clawdbot/hooks/gmail(mapped; isolated run + summary to main).--include-bodyand--max-bytescontrol the body snippet sent to Clawdbot.
clawdbot hooks gmail run wraps the same flow and auto-renews the watch.
Expose the handler (advanced, unsupported)
If you need a non-Tailscale tunnel, wire it manually and use the public URL in the push subscription (unsupported, no guardrails):Test
Send a message to the watched inbox:Troubleshooting
Invalid topicName: project mismatch (topic not in the OAuth client project).User not authorized: missingroles/pubsub.publisheron the topic.- Empty messages: Gmail push only provides
historyId; fetch viagog gmail history.