CRITICAL — Before starting, you MUST first use the Read tool to read ../lark-shared/SKILL.md, which contains authentication and permission handling
Applicable Scenarios
- "Update the announcement of group XX to..." / "Set group announcement"
- "Append a notification at the end of the group announcement" / "Append announcement"
- "See what the current announcement of group XX is" / "Group announcement"
- "Publish a group announcement, @all" / "Publish announcement"
- "Update the project milestone to the group announcement" / "Update announcement"
Prerequisites
Only supports user identity. Ensure authorization before execution:
lark-cli auth login --domain im
Workflow
{chat_id + 操作类型(查看/设置/追加)+ 公告内容}
│
├── im +chat-search ──────────────► 查找群聊(获取 chat_id)
│
├── [查看] lark-cli api GET ──────► 读取当前群公告
│
├── [追加] 先读取再合并 ─────────► 保留旧公告 + 追加新内容
│
├── [设置] lark-cli api PATCH ────► 设置新公告(注意 revision)
│
└── [可选] im +messages-send ────► @全体成员通知公告更新
Step 1: Find the group chat
If the user provided a group name, first get the chat_id:
lark-cli im +chat-search --query "<群名称>" --as user
Extract from the returned result chat_id(oc_xxx format).
Step 2: View the current group announcement
The group announcement API is not directly wrapped by lark-cli, use lark-cli api to call:
# 读取当前群公告
MSYS_NO_PATHCONV=1 lark-cli api GET "/open-apis/im/v1/chats/<chat_id>/announcement" \
--as user
The returned result contains:
content— current announcement HTML contentrevision— version number (must be passed when setting the announcement, used for optimistic concurrency control)
If it returns code: 0 but data is empty, it means there is currently no group announcement.
Step 3: Set the group announcement
Overwrite mode
Completely replace the old announcement with new content:
MSYS_NO_PATHCONV=1 lark-cli api PATCH "/open-apis/im/v1/chats/<chat_id>/announcement" \
--data '{
"revision": "<current_revision>",
"requests": ["<HTML 公告内容>"]
}' \
--as user
Append mode
First read the current announcement, then append new content at the end:
MSYS_NO_PATHCONV=1 lark-cli api PATCH "/open-apis/im/v1/chats/<chat_id>/announcement" \
--data '{
"revision": "<current_revision>",
"requests": ["<旧公告内容><br><br>---<br><br><新追加内容>"]
}' \
--as user
Important:
revisionfieldmustpass the current version number, otherwise it will return an error- The announcement content format is HTML(not Markdown), supports
<br>,<b>,<a href="">,<font color="">and other tagsrequestsis a string array, each element is a piece of HTML content- Before settingyou must first readto get the latest revision
Markdown to HTML Reference
AI needs to convert the Markdown content provided by the user into HTML:
| Markdown | HTML |
|---|---|
**加粗** |
<b>加粗</b> |
# 标题 |
<font size="5"><b>标题</b></font> |
- 列表项 |
列表项<br> |
[链接](url) |
<a href="url">链接</a> |
Step 4: Notify group members (optional)
lark-cli im +messages-send \
--chat-id "<chat_id>" \
--text '<at user_id="all"></at> 群公告已更新,请查看群公告。' \
--as bot
Fallback Strategy
| Scenario | Fallback Plan |
|---|---|
| Group announcement API fails | Send the announcement content to the group as a regular message |
| revision conflict | Re-read to get the latest revision, then set again |
| No group announcement permission | Prompt the user that group admin permission is required |
| Group chat not found | Prompt the user to confirm the group name or provide the chat_id |
| @all restricted | Change to sending a regular message notification |
Permission Table
| Command | Required scope |
|---|---|
im +chat-search |
im:chat:readonly |
im/v1/chats/:id/announcement (GET) |
im:chat:readonly |
im/v1/chats/:id/announcement (PATCH) |
im:chat |
im +messages-send |
im:message |
Reference
../lark-im/SKILL.md— IM atomic operations../lark-openapi-explorer/SKILL.md— Native API call mode