/gws:gws-chatfrom gws
Manages Google Chat spaces, messages, and members via the gws CLI. Useful for listing spaces, sending messages, and monitoring chat events.
Ships in gws. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
gws chat provides CLI access to Google Chat with structured JSON output.
Disclaimer:
gwsis not the official Google CLI. This is an independent, open-source project not endorsed by or affiliated with Google.
Before executing any gws command, verify the CLI is installed:
gws version
If not found, install: go install github.com/omriariav/workspace-cli/cmd/gws@latest
Requires OAuth2 credentials. Run gws auth status to check.
If not authenticated: gws auth login (opens browser for OAuth consent).
For initial setup, see the gws-auth skill.
Note: Google Chat API requires additional setup:
auth_mode: service-account-dwd (see the
gws-auth skill). Note: auth_mode: service-account-app (admin-approved
Chat app credentials) is restricted to gws events subscriptions on
individual Chat spaces; it does NOT enable normal Chat operations such as
send, notify, or space management.| Task | Command |
|---|---|
| Spaces | |
| List chat spaces | gws chat list |
| List spaces (filtered) | gws chat list --filter 'spaceType = "SPACE"' |
| Get space details | gws chat get-space <space-id> |
| Create a space | gws chat create-space --display-name "Team" --type SPACE |
| Delete a space | gws chat delete-space <space-id> |
| Update a space | gws chat update-space <space-id> --display-name "New Name" |
| Search spaces (admin only) | gws chat search-spaces --query "Engineering" |
| Find DM with user | gws chat find-dm --email [email protected] |
| Create space + members | gws chat setup-space --display-name "Team" --members "users/1,users/2" |
| Create DM | gws chat setup-space --type DIRECT_MESSAGE --members "users/123" |
| Create group chat | gws chat setup-space --type GROUP_CHAT --members "users/1,users/2" |
| Build member cache | gws chat build-cache |
| Find group by members | gws chat find-group --members "[email protected],[email protected]" |
| Find space by name | gws chat find-space --name "sales-skills" |
| Messages | |
| Read messages | gws chat messages <space-id> |
| Read recent messages | gws chat messages <space-id> --order-by "createTime DESC" --max 10 |
| Messages after a date | gws chat messages <space-id> --after "2026-02-17T00:00:00Z" |
| Messages in a range | gws chat messages <space-id> --after "2026-02-17T00:00:00Z" --before "2026-02-20T00:00:00Z" |
| Recap recent messages | gws chat recent --since 2h |
| Recap last 7 days | gws chat recent --since 7d --max 1000 |
| Send a message | gws chat send --space <space-id> --text "Hello" |
| Quote a message | gws chat send --space <space-id> --text "Reply" --quote <message-id> |
| Get a single message | gws chat get <message-name> |
| Update a message | gws chat update <message-name> --text "New text" |
| Delete a message | gws chat delete <message-name> |
| Members | |
| List space members | gws chat members <space-id> |
| Get member details | gws chat get-member <member-name> |
| Add a member | gws chat add-member <space-id> --user users/123 |
| Remove a member | gws chat remove-member <member-name> |
| Update member role | gws chat update-member <member-name> --role ROLE_MANAGER |
| Reactions | |
| List reactions | gws chat reactions <message-name> |
| Add a reaction | gws chat react <message-name> --emoji "👍" |
| Remove a reaction | gws chat unreact <reaction-name> |
| Read State | |
| Get read state | gws chat read-state <space-id> |
| Mark space as read | gws chat mark-read <space-id> |
| Get thread read state | gws chat thread-read-state <thread-name> |
| List unread messages | gws chat unread <space-id> |
| Attachments & Media | |
| Get attachment info | gws chat attachment <attachment-name> |
| Upload a file | gws chat upload <space-id> --file ./report.pdf |
| Download media | gws chat download <resource-name> --output ./file.pdf |
| Events | |
| List space events | gws chat events <space-id> --filter 'event_types:"google.workspace.chat.message.v1.created"' |
| Get event details | gws chat event <event-name> |
gws chat list [flags]
Lists all Chat spaces (rooms, DMs, group chats) you have access to. Supports filtering and pagination.
Flags:
--filter string — Filter spaces (e.g. spaceType = "SPACE")--page-size int — Number of spaces per page (default 100)gws chat messages <space-id> [flags]
Flags:
--max int — Maximum number of messages to return (default 25)--after string — Show messages after this time (RFC3339, e.g. 2026-02-17T00:00:00Z)--before string — Show messages before this time (RFC3339, e.g. 2026-02-20T00:00:00Z)--filter string — Filter messages (e.g. createTime > "2024-01-01T00:00:00Z")--order-by string — Order messages (e.g. createTime DESC)--show-deleted — Include deleted messages in results--resolve-senders — Make extra API calls to fill missing sender_display_name (via space membership listing) and add a self boolean (via People API people/me). One extra Chat call per space plus one People call per invocation.--after and --before are convenience shortcuts for --filter. They combine with --filter using AND.
gws chat recent --since <window> [flags]
Recaps Chat messages across every space active within --since, without iterating message history for inactive spaces. Uses spaces.list lastActiveTime as the cheap prefilter, then queries spaces.messages.list per active space with createTime > since and orderBy=createTime DESC. Results are flattened and sorted globally by newest first. Includes both sent and received messages by default.
Flags:
--since string — Time window: a Go duration (2h, 12h, 7d) or RFC3339 timestamp (2026-04-30T09:00:00Z). Default 2h.--max int — Total message cap (default 500, 0 = all)--max-per-space int — Per-space cap (default 100, 0 = all)--max-spaces int — Active-space cap after sorting by lastActiveTime DESC (default 0 = all)--resolve-senders — Fill sender_display_name (one extra membership-list call per active space) and add self via People API--exclude-self — Omit messages sent by the authenticated user (best-effort self detection via People API)Output:
{
"since": "2026-04-30T09:00:00Z",
"spaces_scanned": 123,
"active_spaces": 8,
"count": 42,
"messages": [
{
"space": "spaces/AAAA",
"space_display_name": "Team Chat",
"space_type": "SPACE",
"space_last_active_time": "2026-04-30T10:58:00Z",
"name": "spaces/AAAA/messages/msg1",
"text": "...",
"create_time": "2026-04-30T10:57:00Z",
"sender": "Alice",
"sender_resource": "users/123"
}
]
}
Examples:
gws chat recent --since 2h
gws chat recent --since 12h --resolve-senders --exclude-self
gws chat recent --since 7d --max 1000 --max-per-space 200
gws chat recent --since 2026-04-30T09:00:00Z
Sender attribution fields:
sender — existing display-name-or-resource string. Always present when the message has a sender.sender_type, sender_resource, sender_display_name — additive fields populated from the Chat message payload itself. They appear in default output whenever the API returned them, with no extra calls.self — only populated when --resolve-senders is set and the People API self lookup succeeds. Omitted otherwise rather than guessed.--resolve-senders only adds work for the cases the payload alone can't satisfy: filling sender_display_name when the API didn't include one, and adding self. Failures degrade gracefully — messages stay usable.gws chat members <space-id> [flags]
Lists all members of a Chat space with display names, emails, roles, and user types.
Display names and emails are auto-resolved via the People API and cached locally at ~/.config/gws/user-cache.json. The cache grows over time, avoiding repeat API calls.
Flags:
--max int — Maximum number of members to return (default 100)--filter string — Filter members (e.g. member.type = "HUMAN")--show-groups — Include Google Group memberships--show-invited — Include invited membershipsgws chat send --space <space-id> --text <message>
Flags:
--space string — Space ID or name (required)--text string — Message text (required)--quote string — Message resource name or ID to quote; the CLI fetches the quoted message and sends its current create/update timestamp.--quote-type string — Quote type: reply or forward (default API behavior is reply).--notify string — Notification behavior: none, force, or silent (default none). force and silent require Chat app authentication for message sends, which gws does not support: the service-account-app auth mode only covers gws events subscriptions, so these values are rejected.gws chat get <message-name>
Retrieves a single message by its resource name (e.g. spaces/AAAA/messages/msg1).
Flags:
--resolve-senders — Same additive sender attribution as on chat messages.gws chat update <message-name> --text "New text"
Flags:
--text string — New message text (required)gws chat delete <message-name> [flags]
Flags:
--force — Force delete even if message has repliesgws chat reactions <message-name> [flags]
Flags:
--filter string — Filter reactions (e.g. emoji.unicode = "😀")--page-size int — Number of reactions per page (default 25)gws chat react <message-name> --emoji "👍"
Flags:
--emoji string — Emoji unicode character (required)gws chat unreact <reaction-name>
Removes a reaction by its resource name (e.g. spaces/AAAA/messages/msg1/reactions/rxn1).
gws chat get-space <space>
Retrieves details about a Chat space including name, type, description.
gws chat create-space --display-name "Team Chat" [flags]
Flags:
--display-name string — Space display name (required)--type string — Space type: SPACE or GROUP_CHAT (default SPACE)--description string — Space descriptiongws chat delete-space <space>
gws chat update-space <space> [flags]
Flags:
--display-name string — New display name--description string — New descriptionRequires Workspace admin privileges and
chat.admin.spacesscope. Not available with regular user OAuth.
gws chat search-spaces --query "Engineering" [flags]
Flags:
--query string — Search query (required)--page-size int — Results per page (default 100)gws chat find-dm --email [email protected]
gws chat find-dm --user users/123
Flags:
--user string — User resource name (e.g. users/123)--email string — User email address (e.g. [email protected])# Named space with members
gws chat setup-space --display-name "Project Team" --members "users/111,users/222"
# Direct message (no display-name needed)
gws chat setup-space --type DIRECT_MESSAGE --members "users/111"
# Group chat (no display-name needed)
gws chat setup-space --type GROUP_CHAT --members "users/111,users/222"
Flags:
--display-name string — Space display name (required for SPACE type, forbidden for DM/GROUP_CHAT)--type string — Space type: SPACE, GROUP_CHAT, or DIRECT_MESSAGE (default SPACE)--members string — Comma-separated user resource names (required for DM/GROUP_CHAT)gws chat get-member <member-name>
gws chat add-member <space> --user users/123 [flags]
Flags:
--user string — User resource name (required)--role string — Member role: ROLE_MEMBER or ROLE_MANAGER (default ROLE_MEMBER)gws chat remove-member <member-name>
gws chat update-member <member-name> --role ROLE_MANAGER
Flags:
--role string — New role: ROLE_MEMBER or ROLE_MANAGER (required)gws chat read-state <space>
Returns when you last read the space. Space ID is auto-expanded to the full read state resource name.
gws chat mark-read <space> [flags]
Flags:
--time string — Read time in RFC-3339 format (defaults to now)gws chat thread-read-state <thread-name>
Full resource name required (e.g. users/me/spaces/AAAA/threads/thread1/threadReadState).
gws chat unread <space-id> [flags]
Lists messages received after the last read time. Combines read-state lookup and message filtering.
Flags:
--max int — Maximum number of unread messages (default: 25)--mark-read — Mark space as read after listing--resolve-senders — Same additive sender attribution as on chat messages.gws chat attachment <attachment-name>
Returns metadata: name, content_name, content_type, source, download_uri, thumbnail_uri.
gws chat upload <space> --file ./report.pdf
Flags:
--file string — Path to file to upload (required)gws chat download <resource-name> --output ./file.pdf
Flags:
--output string — Output file path (required)gws chat events <space> --filter 'event_types:"google.workspace.chat.message.v1.created"' [flags]
This polls historical space events on demand. For push delivery of new
events to a Pub/Sub topic (Workspace Events API subscriptions on spaces or
users, including read-state), use the gws-events skill
(gws events subscriptions ...).
Flags:
--filter string — Event type filter (required — API requires it)--page-size int — Events per page (default 100)gws chat event <event-name>
gws chat build-cache # Cache GROUP_CHAT spaces (default)
gws chat build-cache --type all # Cache all space types
gws chat build-cache --type SPACE # Cache only SPACE type
Iterates spaces, fetches members, resolves emails via People API, and stores a local cache at ~/.config/gws/space-members-cache.json. Progress is shown on stderr.
Flags:
--type string — Space type to cache: GROUP_CHAT (default), SPACE, DIRECT_MESSAGE, or allgws chat find-group --members "[email protected],[email protected]"
gws chat find-group --members "[email protected]" --refresh
Searches the local space-members cache for spaces where ALL specified emails are members. Requires build-cache to be run first (or use --refresh).
Flags:
--members string — Comma-separated email addresses to search for (required)--refresh — Rebuild cache before searchinggws chat find-space --name "sales-skills" --refresh
gws chat find-space --name "team" --type SPACE
Searches the local space cache for spaces whose display_name contains the given query (case-insensitive substring match). DMs without a display name are skipped.
Cache scope matters. Default gws chat build-cache only caches GROUP_CHAT. To find SPACE-type rooms (most named spaces) or all types, either:
gws chat build-cache --type SPACE (or --type all), or--refresh so this command rebuilds the cache before searching.Flags:
--name string — Display name substring to search for (case-insensitive, required)--type string — Filter by space type: SPACE, GROUP_CHAT, or DIRECT_MESSAGE--refresh — Rebuild cache before searching (scoped to --type if set, otherwise all types)gws chat list --format json # Structured JSON (default)
gws chat list --format yaml # YAML format
gws chat list --format text # Human-readable text
| Mistake | Correct Usage |
|---|---|
--limit N on messages | Use --max N — --limit does not exist |
find-dm --user [email protected] | Use users/[email protected] format — the --user flag requires a resource name prefix |
setup-space --display-name "X" --type DIRECT_MESSAGE | Omit --display-name for DM/GROUP_CHAT — API rejects it |
find-group without cache | Run gws chat build-cache first, or use --refresh |
Preferred method — use the member cache:
# 1. Build the cache (one-time, or periodically)
gws chat build-cache
# 2. Search by email
gws chat find-group --members "[email protected],[email protected]"
# 3. Get recent messages from the matched space
gws chat messages spaces/AAAApznBCFA --after "2026-02-20T00:00:00Z" --order-by "createTime DESC" --max 25
Alternative — manual search (no cache needed):
# 1. List all spaces, filter to group chats
gws chat list --format json | jq '.spaces | map(select(.type == "GROUP_CHAT")) | .[:10]'
# 2. Check members of candidate spaces
gws chat members spaces/AAAApznBCFA --format json
Key insight: DMs and group chats often have empty display_name — you must check members to identify participants.
# 1. Resolve email to user resource name
gws contacts resolve --email "[email protected]"
# 2. Check if DM already exists
gws chat find-dm --user users/123456
# 3. If not found, create the DM
gws chat setup-space --type DIRECT_MESSAGE --members "users/123456"
# 4. Send a message
gws chat send --space spaces/DMXYZ --text "Hello!"
--format json (the default) for programmatic parsinggws chat list first to get space IDsspaces/AAAA1234spaces/AAAA/messages/msg1members auto-resolves display names via People API — first call may be slower, subsequent calls use cache--order-by "createTime DESC" with messages to get newest first--filter 'createTime > "YYYY-MM-DDT00:00:00Z"' to scope messages to a date range — more reliable than relying on default orderingread-state auto-expands bare space IDs (e.g. AAAA → users/me/spaces/AAAA/spaceReadState)events requires a --filter with event types — see API docsgws-auth skillgws-events skillWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
google-chat, gws, chat-cli, space-management, message-management
Other plugins' skills for the same job
npx claudepluginhub omriariav/workspace-cli --plugin gws16 skills in this plugin
/gws-authGoogle Workspace CLI authentication setup and management. Use when users need to set up OAuth credentials, authenticate with Google APIs, or troubleshoot authentication issues. Triggers: gws auth, google workspace setup, oauth, credentials, client id, api setup./gws-calendarGoogle Calendar CLI operations via gws. Use when users need to list calendars, view events, create/update/delete events, RSVP to invitations, manage calendar CRUD, subscriptions, ACL, free/busy queries, colors, and settings. Triggers: calendar, events, meetings, schedule, rsvp, invite, share, freebusy./gws-contactsGoogle Contacts CLI operations via gws. Use when users need to list, search, view, create, or delete contacts. Triggers: contacts, google contacts, people api, contact management./gws-docsGoogle Docs CLI operations via gws. Use when users need to read, create, or edit Google Docs documents. Triggers: google docs, document, gdoc, word processing./gws-driveGoogle Drive CLI operations via gws. Use when users need to list, search, upload, download, manage files/folders, permissions, approvals, revisions, comments, shared drives, and more. Triggers: drive, files, upload, download, folders, google drive, file management, permissions, approvals, share, shared drives./gws-eventsGoogle Workspace Events API operations via gws. Use when users need to create or manage event subscriptions for Chat, Drive, or Meet resources (Pub/Sub delivery), renew or reactivate subscriptions, or decode Pub/Sub CloudEvent notifications. Triggers: workspace events, event subscription, subscribe to chat events, drive events, meet events, pubsub notifications, cloudevent.