Overview
The gws chat +send helper command provides a simple way to send text messages to Google Chat spaces. It wraps the Chat API’s spaces.messages.create method.
Command Syntax
gws chat +send --space NAME --text TEXT
Parameters
Space name/ID in the format spaces/AAAA.... Use gws chat spaces list to find space names
Plain text message content to send
Examples
Basic message
Send a simple text message:
gws chat +send --space spaces/AAAAxxxx --text 'Hello team!'
Multi-line message
gws chat +send \
--space spaces/AAAAxxxx \
--text 'Build Status:\n✅ Tests passed\n✅ Deploy complete\n\nVersion: 1.2.3'
Using variables
SPACE_ID="spaces/AAAAxxxxYYYYzzzz"
MESSAGE="Deployment to production completed successfully"
gws chat +send --space "$SPACE_ID" --text "$MESSAGE"
Alert notification
ERROR_COUNT=$(grep ERROR /var/log/app.log | wc -l)
if [ "$ERROR_COUNT" -gt 0 ]; then
gws chat +send \
--space spaces/AAAAxxxx \
--text "⚠️ Alert: Found $ERROR_COUNT errors in application logs"
fi
Finding Space Names
Use the Chat API to list spaces and get their IDs:
# List all spaces
gws chat spaces list --params '{"pageSize":50}' --format table
# Get a specific space
gws chat spaces get --params '{"name":"spaces/AAAAxxxx"}'
The space name will be in the format spaces/AAAAxxxxYYYYzzzz.
Returns the created message object:
{
"name": "spaces/AAAAxxxx/messages/xyz123.abc456",
"sender": {
"name": "users/123456789",
"displayName": "Your Name",
"email": "you@example.com",
"type": "HUMAN"
},
"createTime": "2026-03-05T10:30:00.123456Z",
"text": "Hello team!",
"thread": {
"name": "spaces/AAAAxxxx/threads/xyz789"
}
}
How It Works
- Space Validation: The space name must be in the correct format (
spaces/...)
- Message Construction: Builds a JSON body with the
text field
- API Call: Executes
spaces.messages.create with:
- Path parameter:
parent (the space name)
- Request body:
{"text": "..."}
- Authentication: Uses OAuth2 with appropriate Chat API scopes
Limitations
This helper sends plain text messages only. For advanced features, use the raw Chat API:
- Rich formatting: Use
cardsV2 for interactive cards
- Threaded replies: Specify
thread.name or threadKey
- Mentions: Use
<users/123> format in text
- Attachments: Use
attachment field
- Custom names: Use
messageId for idempotency
Example with cards (raw API)
gws chat spaces messages create \
--params '{"parent":"spaces/AAAAxxxx"}' \
--json '{
"cardsV2": [{
"cardId": "unique-card",
"card": {
"header": {"title": "Build Status"},
"sections": [{
"widgets": [{
"textParagraph": {"text": "All tests passed!"}
}]
}]
}
}]
}'
Example with threaded reply
# Reply to an existing thread
gws chat spaces messages create \
--params '{"parent":"spaces/AAAAxxxx"}' \
--json '{
"text": "Reply message",
"thread": {"name": "spaces/AAAAxxxx/threads/xyz789"}
}'
Common Patterns
CI/CD notifications
#!/bin/bash
SPACE="spaces/AAAAxxxx"
if ./run-tests.sh; then
gws chat +send --space "$SPACE" --text "✅ Tests passed (commit: $GIT_SHA)"
else
gws chat +send --space "$SPACE" --text "❌ Tests failed (commit: $GIT_SHA)"
fi
Monitoring alerts
# Cron job to check service health
STATUS=$(curl -s -o /dev/null -w '%{http_code}' https://api.example.com/health)
if [ "$STATUS" != "200" ]; then
gws chat +send \
--space spaces/AAAAxxxx \
--text "🚨 Service health check failed: HTTP $STATUS"
fi
Interactive bot responses
# Read incoming messages and respond
gws chat spaces messages list \
--params '{"parent":"spaces/AAAAxxxx","pageSize":1}' | \
jq -r '.messages[0].text' | \
while read msg; do
response="You said: $msg"
gws chat +send --space spaces/AAAAxxxx --text "$response"
done