gws-events-subscribe

Subscribe to Google Workspace events and stream them as NDJSON via Pub/Sub.

Updated Nov 9, 2023
One-click install
npx skills add https://github.com/oresttokovenko/dot-files --skill gws-events-subscribe-oresttokovenko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gws-events-subscribe
Source: https://github.com/oresttokovenko/dot-files/tree/main/chezmoi/dot_agents/skills/gws-events-subscribe
Command: npx skills add https://github.com/oresttokovenko/dot-files --skill gws-events-subscribe-oresttokovenko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gws.

What problem does it solve? Monitoring changes in Google Workspace resources like Chat spaces normally requires building custom polling loops or webhook infrastructure. This Skill subscribes to Workspace events and streams them as NDJSON, handling Pub/Sub setup and message pulling for you. ## Core Features & Use Cases - Event Subscription: Subscribe to a Workspace resource URI (e.g., a Chat space) and receive CloudEvents matching specified event types. - Pub/Sub Management: Automatically create or reuse Pub/Sub subscriptions, with optional cleanup of created resources on exit. - Flexible Output: Stream events as NDJSON to stdout or write each event to a separate JSON file in an output directory. - Use Case: Watch a Google Chat space for new messages by subscribing to 'google.workspace.chat.message.v1.created' events and piping the NDJSON stream into a logging or alerting pipeline. ## Quick Start Ask the assistant to subscribe to events for a specific Google Chat space using gws events +subscribe with your target resource URI, event types, and GCP project ID.

Frequently Asked Questions about gws-events-subscribe

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I subscribe to Google Workspace events from the command line?

Run gws events +subscribe with the --target flag set to the Workspace resource URI, --event-types for the CloudEvents types, and --project for your GCP project. Events stream to stdout as NDJSON until you press Ctrl-C.

How do I monitor Google Chat messages in real time?

Subscribe to the Chat space resource URI (//chat.googleapis.com/spaces/SPACE_ID) with the event type google.workspace.chat.message.v1.created. The command pulls matching events through Pub/Sub and prints them as NDJSON.

Can I reuse an existing Pub/Sub subscription with gws events?

Yes, pass --subscription with the full subscription path (projects/p/subscriptions/name) to skip Pub/Sub setup. This is useful for reconnecting to a previously created subscription without provisioning new resources.

Does gws events +subscribe delete Pub/Sub resources after running?

By default, created Pub/Sub resources persist so you can reconnect later. Add the --cleanup flag to delete the created Pub/Sub resources automatically when the command exits.

How do I save Workspace events to files instead of stdout?

Use the --output-dir flag to write each received event to a separate JSON file in the specified directory. Without it, events are streamed as NDJSON to standard output.