Labsco
googleworkspace logo

gws-gmail-watch

โœ“ Officialโ˜… 29,425

by Google ยท part of googleworkspace/cli

Gmail: Watch for new emails and stream them as NDJSON.

๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup
๐Ÿงฐ Not standalone. This skill ships with googleworkspace/cli and only works together with that tool โ€” install the tool first, then add this skill.

This is the playbook your agent receives when the skill activates โ€” you don't need to read it to use the skill, but it's here to audit before installing.

gmail +watch

PREREQUISITE: Read ../gws-shared/SKILL.md for auth, global flags, and security rules. If missing, run gws generate-skills to create it.

Watch for new emails and stream them as NDJSON

Flags

FlagRequiredDefaultDescription
--projectโ€”โ€”GCP project ID for Pub/Sub resources
--subscriptionโ€”โ€”Existing Pub/Sub subscription name (skip setup)
--topicโ€”โ€”Existing Pub/Sub topic with Gmail push permission already granted
--label-idsโ€”โ€”Comma-separated Gmail label IDs to filter (e.g., INBOX,UNREAD)
--max-messagesโ€”10Max messages per pull batch
--poll-intervalโ€”5Seconds between pulls
--msg-formatโ€”fullGmail message format: full, metadata, minimal, raw
--onceโ€”โ€”Pull once and exit
--cleanupโ€”โ€”Delete created Pub/Sub resources on exit
--output-dirโ€”โ€”Write each message to a separate JSON file in this directory

Examples

gws gmail +watch --project my-gcp-project
gws gmail +watch --project my-project --label-ids INBOX --once
gws gmail +watch --subscription projects/p/subscriptions/my-sub
gws gmail +watch --project my-project --cleanup --output-dir ./emails

Tips

  • Gmail watch expires after 7 days โ€” re-run to renew.
  • Without --cleanup, Pub/Sub resources persist for reconnection.
  • Press Ctrl-C to stop gracefully.

See Also

  • gws-shared โ€” Global flags and auth
  • gws-gmail โ€” All send, read, and manage email commands