On this page
On this page
CLI commands
Webhooks
openclaw webhooks
openclaw webhooks sets up and runs the Gmail Pub/Sub transport through gog (gogcli). It does not register internal HOOK.md hooks or manage arbitrary Gateway hook mappings.
Subcommands
| Subcommand | Description |
|---|---|
gmail setup |
One-time wizard: Gmail watch, Pub/Sub topic/subscription, and OpenClaw hook delivery. |
gmail run |
Run gog gmail watch serve plus the watch auto-renew loop in the foreground. |
webhooks gmail setup
Authenticates gcloud, enables the required APIs, creates or updates the Pub/Sub topic/subscription and push endpoint, starts the Gmail watch, and writes hooks.gmail with hooks.enabled: true and the Gmail preset. Missing gcloud, gog, and Tailscale dependencies can be installed automatically on macOS with Homebrew. Other platforms need them installed first. The Gmail account must already be authorized in gog.
Setup changes cloud resources, exposure settings, and local config. It is not a read-only check. Re-running it can apply the CLI defaults over saved Gmail settings. It prints Next: openclaw webhooks gmail run. Use that only if the Gateway-managed watcher is not already running.
Required
| Flag | Description |
|---|---|
--account <email> |
Gmail account to watch. |
Pub/Sub options
| Flag | Default | Description |
|---|---|---|
--project <id> |
(none) | GCP project id (the OAuth client owner). Falls back to the topic's own project id, then to the project resolved from gog credentials. |
--topic <name> |
gog-gmail-watch |
Pub/Sub topic name. |
--subscription <name> |
gog-gmail-watch-push |
Pub/Sub subscription name. |
--label <label> |
INBOX |
Gmail label to watch. |
--push-endpoint <url> |
(none) | Explicit Pub/Sub push endpoint. Skips Tailscale endpoint setup; use --tailscale off for externally managed exposure. The URL is used as supplied, including any required push token. |
OpenClaw delivery options
| Flag | Default | Description |
|---|---|---|
--hook-url <url> |
hooks.gmail.hookUrl, then local Gateway URL |
OpenClaw webhook URL; generated fallback uses hooks.path and the Gateway port. |
--hook-token <token> |
hooks.token, or a generated token |
OpenClaw webhook token. |
--push-token <token> |
hooks.gmail.pushToken, or a generated token |
Separate token authenticating Pub/Sub to gog gmail watch serve. |
gog gmail watch serve options
| Flag | Default | Description |
|---|---|---|
--bind <host> |
127.0.0.1 |
gog gmail watch serve bind host. |
--port <port> |
8788 |
gog gmail watch serve port. |
--path <path> |
/gmail-pubsub |
gog gmail watch serve path. Forced to / when Tailscale is enabled without an explicit target, since Tailscale strips the path before proxying. |
--include-body |
true |
Include email body snippets. There is no CLI flag to turn this off; set hooks.gmail.includeBody: false in config instead. |
--max-bytes <n> |
20000 |
Max bytes per body snippet. |
--renew-minutes <n> |
720 (12h) |
Renew Gmail watch every N minutes. |
Tailscale exposure
| Flag | Default | Description |
|---|---|---|
--tailscale <mode> |
funnel |
Expose push endpoint via tailscale: funnel, serve, or off. |
--tailscale-path <path> |
hooks.gmail.tailscale.path, then serve path |
Path for tailscale serve/funnel. |
--tailscale-target <target> |
hooks.gmail.tailscale.target, then local watcher |
Tailscale serve/funnel target (port, host:port, or URL). |
Output
| Flag | Description |
|---|---|
--json |
Print a machine-readable summary instead of text. |
Command failures show bounded tails from both stdout and stderr, with terminal colors and progress redraws removed. Exit codes and recorded termination reasons distinguish timeouts, signals, and output limits. Exit code 124 alone does not mean a timeout. An omission marker (…) indicates truncated output. These diagnostics can still contain sensitive command output: redact them before sharing.
--port, --max-bytes, and --renew-minutes require positive integers, without unit suffixes. --include-body has no negative CLI flag: set hooks.gmail.includeBody: false and let run inherit it.
webhooks gmail run
Checks the selected Gog executable, starts the Gmail watch, and runs gog gmail watch serve plus periodic renewal in the foreground. Gog v0.48.0 and builds exposing both --token-env and --hook-token-env receive tokens through child-only environment sources. OpenClaw supplies the values from existing config; no manual environment exports are needed. A started message means launched, not registered or ready.
Older Gog continues using the existing token arguments, with one warning per watcher lifecycle. Other local users with process visibility can read both the Gmail push token and the shared OpenClaw hook token, which authorizes enabled hook routes. An inconclusive capability check also preserves the existing connection, with a distinct “could not verify” warning. These connections remain affected until Gog is upgraded. Once environment transport is selected, serve failures and automatic restarts never switch back to token arguments. Canceling startup stops it.
Interactive setup and run can offer a Homebrew upgrade when the executable actually selected on PATH belongs to a supported, unpinned Gog formula. Declining keeps the existing connection working. Custom wrappers, pinned formulae, and other installations receive manual upgrade guidance. OpenClaw rechecks the executable and both capabilities after an upgrade, including a failed package operation; it does not assume success or rollback. A formula that has not yet published a supporting build leaves the warning in place. If Gog is no longer executable, repair its installation before retrying.
openclaw doctor reports this for configured Gmail connections. Run openclaw doctor --repair to upgrade an eligible Homebrew installation explicitly. Gateway startup, diagnostic checks, and the Doctor pass inside openclaw update do not upgrade Gog. You can also upgrade with your installation manager; for Homebrew, run brew update and brew upgrade gogcli (or the installed tap-qualified formula). Restart the Gmail watcher afterward, or restart the Gateway for a Gateway-managed watcher. Restart other already-running Gog watchers separately.
Transient serve exits restart after 5 seconds. Bind conflicts retry after 5, 10, and 20 seconds. Ctrl-C or SIGTERM cancels pending startup, restarts, and renewal work and shuts down the process tree.
Prefer config-held tokens: existing --hook-token and --push-token overrides remain accepted, but secrets manually placed on the parent CLI command line remain visible there. Environment handoff does not protect against the process owner or root. One-time setup separately passes a token-bearing Pub/Sub push endpoint to gcloud; this serve-launch change does not remove that setup exposure.
run accepts the same Pub/Sub, OpenClaw delivery, gog gmail watch serve, and Tailscale flags as setup, except:
--accountis optional onrun. It falls back tohooks.gmail.account.rundoes not accept--project,--push-endpoint, or--json.- Unspecified flags inherit the matching
hooks.gmail.*setting.--hook-tokeninheritshooks.token. - Account, full topic path, hook token, and push token must be supplied or configured.
rundoes not generate missing tokens, provision Pub/Sub resources, or rewrite config. - Other fields use the setup defaults when no saved setting exists, except
--tailscale, which defaults tooffrather thanfunnel.
| Category | Flags |
|---|---|
| Pub/Sub | --account, --topic, --subscription, --label |
| OpenClaw delivery | --hook-url, --hook-token, --push-token |
gog gmail watch serve |
--bind, --port, --path, --include-body, --max-bytes, --renew-minutes |
| Tailscale | --tailscale, --tailscale-path, --tailscale-target |
Verify forwarding
Send a test from another account to the watched inbox. The watcher excludes
SPAM, TRASH, DRAFT, and SENT messages. Check watcher forwarding errors,
then the Gateway hook completion/error logs and the reader's run output.
A successful push or HTTP admission response does not prove email processing or
channel delivery completed. Follow the reader boundary
check before connecting an
untrusted inbox.
Related
- CLI reference
- Webhook automation
- Gmail Pub/Sub integration
- Configuration reference — where each webhook setting is documented