简介
基于 Google 官方 API 的双模式消息推送方案,支持 Webhook 快速通知与 OAuth 动态消息,为团队提供安全可靠的自动化协作能力。
原始描述
Send messages to Google Chat spaces and users via webhooks or OAuth. Use when you need to send notifications, alerts, or messages to Google Chat channels (spaces) or direct messages to specific users. Supports both incoming webhooks (for predefined channels) and OAuth 2.0 (for dynamic messaging to any space or user).
通过你的 Agent 添加
安装目录:google-chat/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Google Chat 消息推送技能提供两种发送方式:Webhook 模式适用于固定频道的快速通知,通过预配置的 URL 直接发送消息,无需认证流程,适合 CI/CD 流水线、系统告警等高频场景;OAuth 模式支持动态发送到任意空间或用户,通过 Google 官方 OAuth 2.0 流程获取授权,适合需要根据运行时不确定目标的应用场景。
显著优点
- 双模式灵活架构:Webhook 追求极致速度,OAuth 提供全功能覆盖,用户可按场景选择最优方案
- 线程消息支持:Webhook 模式下可通过 thread_key 实现消息线程聚合,保持对话上下文完整
- 官方生态集成:基于 Google Cloud 官方 API 构建,与企业 Google Workspace 环境无缝兼容
- 卡片消息格式:支持 Google Chat Cards V2 格式,可构建富媒体交互式通知
- 安全合规设计:OAuth 流程完全遵循 Google 安全标准,Token 本地存储由用户自主控制
潜在局限
- OAuth DM 限制:无法通过邮箱直接创建新私信,需预先存在的对话空间 ID
- 动态空间发现:需先调用 --list-spaces 获取空间列表,无法直接通过名称模糊匹配
- 配置前置要求:Webhook 需手动在 Chat 界面配置,OAuth 需完成 Cloud Console 项目设置
- 网络依赖:完全依赖 Google 服务可用性,企业内网隔离环境需额外代理配置
- emoji 前缀行为:OAuth 消息默认添加 🤖 前缀,虽可禁用但增加用户认知成本
适合群体
- DevOps 工程师:构建部署通知、构建状态告警流水线
- 运维团队:监控系统集成、值班轮替自动通知
- 企业 IT 管理员:Workspace 环境下的自动化消息分发
- 产品经理/项目经理:项目里程碑、任务状态自动广播
使用风险
风险类型
说明
缓解建议
凭证泄露
Webhook URL 含身份令牌,OAuth 文件存储敏感凭证
配置文件排除在版本控制外,设置 600 文件权限
Token 过期
OAuth token 存在有效期,长期运行可能中断
实现自动刷新机制或定期重新认证
速率限制
Google API 存在配额限制
批量消息增加延迟,监控 429 错误并退避重试
依赖维护
官方库更新可能引入 Breaking Changes
锁定版本或建立自动化测试覆盖
网络中断
外网不通时消息堆积或丢失
关键告警配置本地队列或降级通道
- OAuth DM 限制:无法通过邮箱直接创建新私信,需预先存在的对话空间 ID
- 动态空间发现:需先调用 --list-spaces 获取空间列表,无法直接通过名称模糊匹配
- 配置前置要求:Webhook 需手动在 Chat 界面配置,OAuth 需完成 Cloud Console 项目设置
- 网络依赖:完全依赖 Google 服务可用性,企业内网隔离环境需额外代理配置
- emoji 前缀行为:OAuth 消息默认添加 🤖 前缀,虽可禁用但增加用户认知成本
适合群体
- DevOps 工程师:构建部署通知、构建状态告警流水线
- 运维团队:监控系统集成、值班轮替自动通知
- 企业 IT 管理员:Workspace 环境下的自动化消息分发
- 产品经理/项目经理:项目里程碑、任务状态自动广播
使用风险
风险类型
说明
缓解建议
凭证泄露
Webhook URL 含身份令牌,OAuth 文件存储敏感凭证
配置文件排除在版本控制外,设置 600 文件权限
Token 过期
OAuth token 存在有效期,长期运行可能中断
实现自动刷新机制或定期重新认证
速率限制
Google API 存在配额限制
批量消息增加延迟,监控 429 错误并退避重试
依赖维护
官方库更新可能引入 Breaking Changes
锁定版本或建立自动化测试覆盖
网络中断
外网不通时消息堆积或丢失
关键告警配置本地队列或降级通道
| 风险类型 | 说明 | 缓解建议 |
|---|---|---|
| 凭证泄露 | Webhook URL 含身份令牌,OAuth 文件存储敏感凭证 | 配置文件排除在版本控制外,设置 600 文件权限 |
| Token 过期 | OAuth token 存在有效期,长期运行可能中断 | 实现自动刷新机制或定期重新认证 |
| 速率限制 | Google API 存在配额限制 | 批量消息增加延迟,监控 429 错误并退避重试 |
| 依赖维护 | 官方库更新可能引入 Breaking Changes | 锁定版本或建立自动化测试覆盖 |
| 网络中断 | 外网不通时消息堆积或丢失 | 关键告警配置本地队列或降级通道 |
技能正文
name: google-chat
description: >
CRITICAL: You MUST activate this skill BEFORE sending, reading, or managing
Google Chat messages. Always trigger this skill as the first step when the
user mentions "chat", "google chat", "message a space", "DM", or sending a
chat message. Contains strict formatting mandates that override default
messaging behavior.
Google Chat Expert
You are an expert at messaging and managing conversations through the Google Chat API. Follow these guidelines when helping users with chat tasks.
Chat Message Formatting
When composing messages (via chat.sendMessage or chat.sendDm), always use
Google Chat's supported markdown syntax. Google Chat uses a specific subset of
markdown that differs from standard markdown. You MUST convert any unsupported
syntax before sending.
Supported Formatting
Syntax
Renders As
Example
*text*
bold
*Important update*
_text_
italic
_Please review_
~text~
strikethrough
~no longer relevant~
`code`
inline code
`git status`
```
code block
```\ncode\n```
* or -
bulleted list
* Item one\n* Item two
<url|text>
hyperlink
<https://example.com|Click>
<users/{userId}>
@mention
<users/12345678>
Unsupported Syntax (Convert These)
| Syntax | Renders As | Example |
|---|---|---|
*text* |
bold | *Important update* |
_text_ |
italic | _Please review_ |
~text~ |
~no longer relevant~ |
|
`code` |
inline code |
`git status` |
``` |
code block | ```\ncode\n``` |
* or - |
bulleted list | * Item one\n* Item two |
<url|text> |
hyperlink | <https://example.com|Click> |
<users/{userId}> |
@mention | <users/12345678> |
Always convert these before sending a message to Chat:
| Unsupported Syntax | Convert To |
|---|---|
**bold** (double *) |
*bold* (single *) |
[text](url) markdown link |
<url|text> Chat link format |
# Heading |
*Heading* (bold text) |
| Nested lists | Flatten to a single-level list. |
> blockquote |
Preserve the > character as-is |
Message Formatting Examples
Status Update
*Project Status Update*
_Sprint 14 Summary:_
* Completed 12 of 15 story points
* ~Deferred analytics dashboard~ (moved to Sprint 15)
* Key PR: <https://github.com/org/repo/pull/42|#42 - Auth refactor>
Next steps: `deploy-staging` pipeline runs tonight.
Code Snippet
Found the bug. The issue is in the handler:
```
func handleRequest(ctx context.Context) error {
// Missing nil check here
if ctx == nil {
return ErrNilContext
}
return process(ctx)
}
```
<users/12345678> can you review this fix?
Spaces vs. Direct Messages
Found the bug. The issue is in the handler:
```
func handleRequest(ctx context.Context) error {
// Missing nil check here
if ctx == nil {
return ErrNilContext
}
return process(ctx)
}
```
<users/12345678> can you review this fix?
Google Chat has two main messaging contexts. Use the right tool for each:
Spaces (Group Conversations)
Spaces are shared group conversations with a display name.
| Action | Tool | Key Parameter |
|---|---|---|
| Find a space | chat.findSpaceByName |
displayName |
| List all spaces | chat.listSpaces |
(none) |
| Send a message | chat.sendMessage |
spaceName, message |
| Create a new space | chat.setUpSpace |
displayName, userNames |
Direct Messages (1:1)
DMs are private conversations between two users, identified by email.
| Action | Tool | Key Parameter |
|---|---|---|
| Find a DM space | chat.findDmByEmail |
email |
| Send a DM | chat.sendDm |
email, message |
Note:
chat.sendDmandchat.findDmByEmailboth usespaces.setupunder the hood. If no DM space exists with the user, one is automatically created. There is no need to create a DM space separately.
Limitation: DM tools only support 1:1 conversations. For group conversations (3+ people), use
chat.setUpSpaceto create a named space instead.
Threading
Threads keep related messages grouped together within a space. Use the
threadName parameter to reply in an existing thread.
How Threading Works
- Start a new thread: Send a message without
threadName. The response
will include a thread.name you can use for replies.
- Reply to a thread: Pass
threadName when calling chat.sendMessage or
chat.sendDm. The API uses REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD — if the
thread doesn't exist, a new thread is created.
- List threads: Use
chat.listThreads to discover threads in a space. It
returns the most recent message of each unique thread in reverse
chronological order.
- Get thread messages: Use
chat.getMessages with the threadName
parameter to get all messages in a specific thread.
Thread Example Workflow
1. chat.listThreads({ spaceName: "spaces/AAAAN2J52O8" })
→ Returns threads with thread.name values
2. chat.getMessages({
spaceName: "spaces/AAAAN2J52O8",
threadName: "spaces/AAAAN2J52O8/threads/IAf4cnLqYfg"
})
→ Returns all messages in that thread
3. chat.sendMessage({
spaceName: "spaces/AAAAN2J52O8",
message: "Thanks for the update!",
threadName: "spaces/AAAAN2J52O8/threads/IAf4cnLqYfg"
})
→ Replies in the same thread
Unread Messages
threadName. The response
will include a thread.name you can use for replies.threadName when calling chat.sendMessage or
chat.sendDm. The API uses REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD — if the
thread doesn't exist, a new thread is created.chat.listThreads to discover threads in a space. It
returns the most recent message of each unique thread in reverse
chronological order.chat.getMessages with the threadName
parameter to get all messages in a specific thread.1. chat.listThreads({ spaceName: "spaces/AAAAN2J52O8" })
→ Returns threads with thread.name values
2. chat.getMessages({
spaceName: "spaces/AAAAN2J52O8",
threadName: "spaces/AAAAN2J52O8/threads/IAf4cnLqYfg"
})
→ Returns all messages in that thread
3. chat.sendMessage({
spaceName: "spaces/AAAAN2J52O8",
message: "Thanks for the update!",
threadName: "spaces/AAAAN2J52O8/threads/IAf4cnLqYfg"
})
→ Replies in the same thread
Unread Messages
Use unreadOnly: true on chat.getMessages to filter for unread messages only.
How It Works
The unread filter:
- Looks up the authenticated user's ID via the People API
- Finds the user's membership in the space
- Uses the
lastReadTimefrom the membership to filter messages created after that timestamp - If no
lastReadTimeis found, all messages are returned (treats everything as unread)
Combining Filters
You can combine unreadOnly with threadName to get unread messages in a
specific thread. The filters are joined with AND:
chat.getMessages({
spaceName: "spaces/AAAAN2J52O8",
threadName: "spaces/AAAAN2J52O8/threads/IAf4cnLqYfg",
unreadOnly: true
})
Space Management
Creating a Space
Use chat.setUpSpace to create a new named space with members:
chat.setUpSpace({
displayName: "Q1 Planning",
userNames: ["users/12345678", "users/87654321"]
})
Important: The
userNamesparameter expects user resource names in the formatusers/{userId}, not email addresses. Usepeople.getUserProfileto look up user IDs and convert thepeople/{id}resource name tousers/{id}.
Resource Name Formats
Google Chat uses structured resource names. Here is a quick reference:
| Resource | Format | Example |
|---|---|---|
| Space | spaces/{spaceId} |
spaces/AAAAN2J52O8 |
| Message | spaces/{spaceId}/messages/{messageId} |
spaces/AAAAN2J52O8/messages/abc123 |
| Thread | spaces/{spaceId}/threads/{threadId} |
spaces/AAAAN2J52O8/threads/IAf4cnLqYfg |
| User | users/{userId} |
users/12345678 |