feishu-cli-chat

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

飞书会话浏览与管理

Feishu Chat Browsing and Management

通过 feishu-cli 浏览飞书单聊/群聊消息历史、搜索会话、管理群聊信息和成员。
Browse Feishu one-on-one/group chat message history, search conversations, manage group chat information and members via feishu-cli.

前置条件

Prerequisites

本技能的核心命令必须使用 User Token,使用前需先登录。
chat create
chat link
msg read-users
使用 App Token,属于 feishu-cli-toolkit 技能。
bash
feishu-cli auth login
未登录时命令会直接报错并提示登录方式。登录后 token 自动加载,无需手动传参。
The core commands of this skill must use User Token, please log in first.
chat create
,
chat link
,
msg read-users
use App Token and belong to the feishu-cli-toolkit skill.
bash
feishu-cli auth login
Commands will directly report an error and prompt login methods if not logged in. The token is automatically loaded after login, no need to pass parameters manually.

身份说明

Identity Description

身份使用场景
User Token(必须)本技能所有读取/管理命令:chat get/update/delete、member list/add/remove、msg get/history/list/pins/reaction/search-chats、search messages
App Token
chat create
chat link
msg read-users
(这三个命令不属于本技能核心流程)
User Token 能力:
  • 查看 bot 不在的群聊消息
  • 查看私聊(p2p)消息
  • 搜索用户有权限的所有会话
IdentityUsage Scenario
User Token (Required)All read/management commands of this skill: chat get/update/delete, member list/add/remove, msg get/history/list/pins/reaction/search-chats, search messages
App TokenOnly
chat create
,
chat link
,
msg read-users
(these three commands are not part of the core process of this skill)
User Token Capabilities:
  • View group chat messages that the bot is not in
  • View one-on-one (p2p) chat messages
  • Search all conversations that the user has permission to access

自动降级机制

Automatic Downgrade Mechanism

当使用 User Token 调用
msg history
/
msg list
时,如果 bot 不在目标群中,API 会返回空结果。CLI 会自动检测这种情况并降级为 search + get 方式获取消息:
list API 返回空 + has_more=true → 自动切换到搜索模式 → 逐条获取消息内容
这个过程对用户透明,无需手动干预。

When using User Token to call
msg history
/
msg list
, if the bot is not in the target group, the API will return an empty result. The CLI will automatically detect this situation and downgrade to the search + get method to retrieve messages:
List API returns empty + has_more=true → automatically switch to search mode → retrieve message content one by one
This process is transparent to users, no manual intervention required.

场景一:查看群聊历史消息

Scenario 1: View Group Chat History Messages

这是最常见的场景——用户想看某个群最近在聊什么。
This is the most common scenario - users want to see what a group has been discussing recently.

步骤 1:找到群聊

Step 1: Locate the Group Chat

如果用户给了群名而不是 chat_id,先搜索:
bash
feishu-cli msg search-chats --query "群名关键词" -o json
输出中的
chat_id
(形如
oc_xxx
)就是后续命令需要的标识。
If the user provides a group name instead of chat_id, search first:
bash
feishu-cli msg search-chats --query "group name keywords" -o json
The
chat_id
(in the format
oc_xxx
) in the output is the identifier required for subsequent commands.

步骤 2:获取消息

Step 2: Retrieve Messages

bash
undefined
bash
undefined

获取最近 50 条消息(API 单次上限 50)

Get the latest 50 messages (API single request limit is 50)

feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--sort-type ByCreateTimeDesc
-o json
feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--sort-type ByCreateTimeDesc
-o json

按时间范围获取(--start-time 为毫秒级时间戳,仅返回该时间之后的消息)

Retrieve by time range (--start-time is a millisecond timestamp, only returns messages after this time)

feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--start-time 1773778860000
--sort-type ByCreateTimeDesc
-o json
feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--start-time 1773778860000
--sort-type ByCreateTimeDesc
-o json

获取更早的消息(使用上一次返回的 page_token 翻页)

Retrieve older messages (use the page_token returned from the previous page for pagination)

feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--page-token "上一页返回的token"
-o json
undefined
feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--page-token "token returned from previous page"
-o json
undefined

步骤 2.5:判断群类型并获取线程回复

Step 2.5: Determine Group Type and Retrieve Thread Replies

飞书群聊分为普通群话题群两种,消息结构和获取策略完全不同。
Feishu group chats are divided into regular groups and topic groups, with completely different message structures and retrieval strategies.

如何判断群类型

How to Determine Group Type

观察
msg history
返回的消息字段:
群类型特征示例
话题群每条消息都有
thread_id
(形如
omt_xxx
),主消息流仅包含每个话题的首条消息
泰国华商群
普通群独立消息
thread_id
,仅被回复的消息和回复消息才有
thread_id
Claude Code闲聊群
Observe the message fields returned by
msg history
:
Group TypeCharacteristicsExample
Topic GroupEvery message has a
thread_id
(in the format
omt_xxx
), the main message stream only contains the first message of each topic
Thai Chinese Business Group
Regular GroupIndependent messages have no
thread_id
, only replied messages and reply messages have
thread_id
Claude Code Casual Chat Group

消息中的线程相关字段

Thread-related Fields in Messages

字段说明出现条件
thread_id
线程/话题 ID(形如
omt_xxx
话题群所有消息 / 普通群中参与线程的消息
root_id
线程根消息 ID(即话题首条消息)线程回复消息
parent_id
直接上级消息 ID(被回复的那条消息)线程回复消息
FieldDescriptionOccurrence Condition
thread_id
Thread/topic ID (in the format
omt_xxx
)
All messages in topic groups / messages participating in threads in regular groups
root_id
Thread root message ID (i.e., the first message of the topic)Thread reply messages
parent_id
Direct parent message ID (the message being replied to)Thread reply messages

普通群:一次获取全部消息

Regular Group: Retrieve All Messages at Once

普通群的
msg history
返回所有消息(独立消息 + 线程回复),平铺在同一列表中。通过
root_id
/
parent_id
可重建回复关系,不需要额外获取线程。
独立消息:       无 thread_id、无 root_id
被回复的消息:   有 thread_id(被回复后自动产生)
线程回复:       有 thread_id + root_id + parent_id
msg history
for regular groups returns all messages (independent messages + thread replies), flattened in the same list. The reply relationship can be reconstructed via
root_id
/
parent_id
, no need to retrieve threads additionally.
Independent message:       No thread_id, no root_id
Replied message:   Has thread_id (automatically generated after being replied)
Thread reply:       Has thread_id + root_id + parent_id

话题群:需要逐个话题获取回复(重要)

Topic Group: Need to Retrieve Replies by Topic (Important)

话题群的
msg history --container-id-type chat
仅返回每个话题的首条消息,线程回复不在主消息流中。必须按 thread_id 逐个获取:
bash
undefined
msg history --container-id-type chat
for topic groups only returns the first message of each topic, thread replies are not in the main message stream. You must retrieve them individually by thread_id:
bash
undefined

获取单个话题的所有回复(按时间正序,方便阅读)

Retrieve all replies of a single topic (sorted in chronological order for easy reading)

feishu-cli msg history
--container-id omt_xxx
--container-id-type thread
--page-size 50
--sort-type ByCreateTimeAsc
-o json

**完整的话题群获取流程**:

```bash
feishu-cli msg history
--container-id omt_xxx
--container-id-type thread
--page-size 50
--sort-type ByCreateTimeAsc
-o json

**Complete Topic Group Retrieval Process**:

```bash

1. 获取主消息流(每个话题的首条消息)

1. Retrieve the main message stream (first message of each topic)

feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--sort-type ByCreateTimeDesc
-o json
feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--sort-type ByCreateTimeDesc
-o json

2. 从返回结果中提取所有 thread_id

2. Extract all thread_id from the returned results

3. 对每个 thread_id 获取回复(可并发执行,提高效率)

3. Retrieve replies for each thread_id (can be executed concurrently to improve efficiency)

feishu-cli msg history --container-id omt_xxx --container-id-type thread --page-size 50 --sort-type ByCreateTimeAsc -o json feishu-cli msg history --container-id omt_yyy --container-id-type thread --page-size 50 --sort-type ByCreateTimeAsc -o json
feishu-cli msg history --container-id omt_xxx --container-id-type thread --page-size 50 --sort-type ByCreateTimeAsc -o json feishu-cli msg history --container-id omt_yyy --container-id-type thread --page-size 50 --sort-type ByCreateTimeAsc -o json

... 多个话题可并行获取

... Multiple topics can be retrieved in parallel


> **性能提示**:话题群中活跃话题可能有 10-20 个,建议**并发获取**多个话题的回复。飞书 API 对 `msg history` 无严格 QPS 限制(不同于搜索 API),可以安全并发。

> **Performance Tip**: Active topics in topic groups may have 10-20 entries, it is recommended to **retrieve multiple topics concurrently**. Feishu API has no strict QPS limit for `msg history` (unlike the Search API), so concurrent calls are safe.

步骤 3:解析消息内容

Step 3: Parse Message Content

API 返回的消息 body.content 是 JSON 字符串,常见格式:
msg_typecontent 格式说明
text
{"text":"消息内容"}
纯文本,
@_user_1
是 at 占位符
post富文本 JSON包含标题和段落结构
image
{"image_key":"xxx"}
图片
interactive卡片 JSON交互式卡片
share_calendar_event
{"summary":"会议名","start_time":"ms","end_time":"ms",...}
日历事件分享
sticker
{"sticker_key":"xxx"}
表情包
file
{"file_key":"xxx","file_name":"..."}
文件
用 Python 提取文本内容的常用方式:
python
import json
content = json.loads(msg['body']['content'])
text = content.get('text', '')
The
body.content
returned by the API is a JSON string, common formats:
msg_typecontent FormatDescription
text
{"text":"message content"}
Plain text,
@_user_1
is an at placeholder
postRich text JSONContains title and paragraph structure
image
{"image_key":"xxx"}
Image
interactiveCard JSONInteractive card
share_calendar_event
{"summary":"meeting name","start_time":"ms","end_time":"ms",...}
Calendar event share
sticker
{"sticker_key":"xxx"}
Sticker
file
{"file_key":"xxx","file_name":"..."}
File
Common way to extract text content using Python:
python
import json
content = json.loads(msg['body']['content'])
text = content.get('text', '')

完整示例:获取并总结群聊最近 N 条消息

Complete Example: Retrieve and Summarize the Latest N Messages of a Group Chat

bash
undefined
bash
undefined

1. 搜索群聊

1. Search for the group chat

feishu-cli msg search-chats --query "Go讨论区" -o json
feishu-cli msg search-chats --query "Go Discussion Group" -o json

2. 获取消息(循环翻页直到够数)

2. Retrieve messages (loop pagination until enough messages are obtained)

feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--sort-type ByCreateTimeDesc
-o json > /tmp/chat_page1.json
feishu-cli msg history
--container-id oc_xxx
--container-id-type chat
--page-size 50
--sort-type ByCreateTimeDesc
-o json > /tmp/chat_page1.json

3. 提取 page_token 获取下一页

3. Extract page_token to retrieve the next page

... 循环直到获取足够消息

... Loop until enough messages are obtained or has_more=false


> **注意**:Search API 的 page_size 与 List API 不同,降级模式下每页实际返回数量可能少于请求值。建议循环翻页直到 `has_more=false` 或达到目标数量。

---

> **Note**: The page_size of the Search API is different from that of the List API, the actual number of returned items per page may be less than the requested value in downgrade mode. It is recommended to loop pagination until `has_more=false` or the target number is reached.

---

场景二:查看和某人的私聊记录

Scenario 2: View One-on-one Chat History with Someone

飞书 Open API 不支持直接按用户查询 p2p 聊天记录。需要通过搜索 API 间接实现。
Feishu Open API does not support directly querying p2p chat records by user. It needs to be implemented indirectly through the Search API.

方法:搜索 + 筛选

Method: Search + Filter

bash
undefined
bash
undefined

搜索私聊消息

Search one-on-one chat messages

feishu-cli search messages "关键词"
--chat-type p2p_chat
-o json
feishu-cli search messages "keywords"
--chat-type p2p_chat
-o json

如果知道对方的 open_id,可以按发送者筛选

If you know the other party's open_id, filter by sender

feishu-cli search messages "关键词"
--chat-type p2p_chat
--from-ids ou_xxx
-o json
feishu-cli search messages "keywords"
--chat-type p2p_chat
--from-ids ou_xxx
-o json

获取单条消息详情

Retrieve details of a single message

feishu-cli msg get om_xxx -o json
undefined
feishu-cli msg get om_xxx -o json
undefined

查找用户 ID

Find User ID

如果用户只给了邮箱或手机号,可以查找对应的 open_id:
bash
undefined
If the user only provides an email or mobile phone number, you can find the corresponding open_id:
bash
undefined

通过邮箱查找用户

Find user by email

feishu-cli user search --email user@example.com -o json
feishu-cli user search --email user@example.com -o json

通过手机号查找用户

Find user by mobile phone number

feishu-cli user search --mobile 13800138000 -o json

> **注意**:`user search` 仅支持 `--email` 和 `--mobile` 精确查找,不支持按姓名模糊搜索。
feishu-cli user search --mobile 13800138000 -o json

> **Note**: `user search` only supports exact search via `--email` and `--mobile`, fuzzy search by name is not supported.

限制说明

Restrictions

  • 搜索 API 的
    query
    参数不能为空,至少需要一个空格
    " "
  • p2p 聊天无法通过
    msg search-chats
    搜索(该 API 只搜索群聊)
  • 搜索结果返回的是消息 ID 列表,需要逐条
    msg get
    获取完整内容
  • msg get
    对私聊消息可能返回 230001 错误
    (API 限制:部分私聊消息不支持通过 Get API 获取详情),此时只能依赖搜索结果中的摘要信息

  • The
    query
    parameter of the Search API cannot be empty, at least one space
    " "
    is required
  • p2p chats cannot be searched via
    msg search-chats
    (this API only searches group chats)
  • The search results return a list of message IDs, you need to call
    msg get
    one by one to get the complete content
  • msg get
    may return error 230001 for one-on-one chat messages
    (API restriction: some one-on-one chat messages do not support getting details via the Get API), in this case, you can only rely on the summary information in the search results

场景三:搜索群聊

Scenario 3: Search Group Chats

搜索群聊列表

Search Group Chat List

bash
undefined
bash
undefined

按关键词搜索群聊

Search group chats by keyword

feishu-cli msg search-chats --query "关键词" -o json
feishu-cli msg search-chats --query "keywords" -o json

分页获取所有群

Retrieve all groups with pagination

feishu-cli msg search-chats --page-size 100 -o json
undefined
feishu-cli msg search-chats --page-size 100 -o json
undefined

在群内搜索消息

Search Messages Within a Group

bash
undefined
bash
undefined

在指定群中搜索消息

Search messages in a specified group

feishu-cli search messages "关键词" --chat-ids oc_xxx -o json

> **更多搜索功能**(按时间范围、消息类型、发送者、跨模块搜索文档/应用等)请使用 **feishu-cli-search** 技能,提供完整的筛选参数和 Token 排错指南。

---
feishu-cli search messages "keywords" --chat-ids oc_xxx -o json

> **More Search Features** (by time range, message type, sender, cross-module search for documents/apps, etc.) Please use the **feishu-cli-search** skill, which provides complete filtering parameters and Token troubleshooting guides.

---

场景四:群聊信息管理

Scenario 4: Group Chat Information Management

查看群信息

View Group Information

bash
feishu-cli chat get oc_xxx
默认输出 JSON 格式,包含群名、描述、群主、群类型、成员数量等。
bash
feishu-cli chat get oc_xxx
The default output is in JSON format, including group name, description, group owner, group type, member count, etc.

查看群成员

View Group Members

bash
undefined
bash
undefined

获取成员列表

Retrieve member list

feishu-cli chat member list oc_xxx
feishu-cli chat member list oc_xxx

指定 ID 类型

Specify ID type

feishu-cli chat member list oc_xxx --member-id-type user_id
feishu-cli chat member list oc_xxx --member-id-type user_id

分页获取(大群)

Retrieve with pagination (for large groups)

feishu-cli chat member list oc_xxx --page-size 100 --page-token "xxx"

> **Scope 要求**:使用 User Token 时需要 `im:chat:readonly` 或 `im:chat.members:read` scope。若报 99991679 错误,需通过 `auth login --scopes "... im:chat:readonly"` 重新授权。
feishu-cli chat member list oc_xxx --page-size 100 --page-token "xxx"

> **Scope Requirement**: When using User Token, the `im:chat:readonly` or `im:chat.members:read` scope is required. If error 99991679 is reported, re-authorize via `auth login --scopes "... im:chat:readonly"`.

修改群信息

Modify Group Information

bash
undefined
bash
undefined

改群名

Change group name

feishu-cli chat update oc_xxx --name "新群名"
feishu-cli chat update oc_xxx --name "new group name"

改群描述

Change group description

feishu-cli chat update oc_xxx --description "新的群描述"
feishu-cli chat update oc_xxx --description "new group description"

转让群主

Transfer group ownership

feishu-cli chat update oc_xxx --owner-id ou_xxx
undefined
feishu-cli chat update oc_xxx --owner-id ou_xxx
undefined

群成员管理

Group Member Management

bash
undefined
bash
undefined

添加成员

Add members

feishu-cli chat member add oc_xxx --id-list ou_xxx,ou_yyy
feishu-cli chat member add oc_xxx --id-list ou_xxx,ou_yyy

移除成员

Remove members

feishu-cli chat member remove oc_xxx --id-list ou_xxx
feishu-cli chat member remove oc_xxx --id-list ou_xxx

使用 user_id 类型

Use user_id type

feishu-cli chat member add oc_xxx --id-list user_xxx --member-id-type user_id
undefined
feishu-cli chat member add oc_xxx --id-list user_xxx --member-id-type user_id
undefined

创建群聊

Create Group Chat

bash
feishu-cli chat create --name "新群聊" --user-ids ou_xxx,ou_yyy
注意
chat create
chat link
(获取分享链接)仅支持 App Token(租户身份),不支持 User Token。
bash
feishu-cli chat create --name "new group chat" --user-ids ou_xxx,ou_yyy
Note:
chat create
and
chat link
(get share link) only support App Token (tenant identity), not User Token.

解散群聊

Dissolve Group Chat

bash
feishu-cli chat delete oc_xxx
bash
feishu-cli chat delete oc_xxx

会要求确认,不可逆操作

Confirmation is required, irreversible operation


---

---

场景五:消息详情与互动

Scenario 5: Message Details and Interaction

获取单条消息详情

Retrieve Details of a Single Message

bash
feishu-cli msg get om_xxx -o json
bash
feishu-cli msg get om_xxx -o json

查看消息已读情况

View Message Read Status

bash
feishu-cli msg read-users om_xxx -o json
限制:仅支持查询 bot 自己发送的、7 天内的消息,且 bot 必须在会话内。此命令仅使用 App Token。
bash
feishu-cli msg read-users om_xxx -o json
Restriction: Only supports querying messages sent by the bot itself within 7 days, and the bot must be in the conversation. This command only uses App Token.

查看群内置顶消息

View Pinned Messages in Group

bash
feishu-cli msg pins --chat-id oc_xxx -o json
bash
feishu-cli msg pins --chat-id oc_xxx -o json

置顶/取消置顶消息

Pin/Unpin Messages

bash
undefined
bash
undefined

置顶消息

Pin message

feishu-cli msg pin <message_id>
feishu-cli msg pin <message_id>

取消置顶

Unpin message

feishu-cli msg unpin <message_id>
undefined
feishu-cli msg unpin <message_id>
undefined

Reaction 表情回应

Reaction Emoji Responses

bash
undefined
bash
undefined

添加表情

Add emoji

feishu-cli msg reaction add <message_id> --emoji-type THUMBSUP
feishu-cli msg reaction add <message_id> --emoji-type THUMBSUP

删除表情

Remove emoji

feishu-cli msg reaction remove <message_id> --reaction-id <REACTION_ID>
feishu-cli msg reaction remove <message_id> --reaction-id <REACTION_ID>

查询表情列表

Query emoji list

feishu-cli msg reaction list <message_id> [--emoji-type THUMBSUP] [--page-size 20]

常用 emoji-type:`THUMBSUP`(点赞)、`SMILE`(微笑)、`LAUGH`(大笑)、`HEART`(爱心)、`JIAYI`(加一)、`OK`、`FIRE`
feishu-cli msg reaction list <message_id> [--emoji-type THUMBSUP] [--page-size 20]

Common emoji-type: `THUMBSUP` (Like), `SMILE` (Smile), `LAUGH` (Laugh), `HEART` (Love), `JIAYI` (Plus One), `OK`, `FIRE`

删除消息

Delete Message

仅能删除机器人自己发送的消息,不可恢复。
bash
feishu-cli msg delete <message_id>

Only messages sent by the bot itself can be deleted, and it is irreversible.
bash
feishu-cli msg delete <message_id>

常见操作速查表

Quick Reference Table for Common Operations

用户意图命令Token
看某群最近消息
msg history --container-id oc_xxx --container-id-type chat
User
看话题群的线程回复
msg history --container-id omt_xxx --container-id-type thread
User
看和某人的聊天
search messages " " --chat-type p2p_chat --from-ids ou_xxx
User
搜索群聊
msg search-chats --query "关键词"
User
在群内搜索消息
search messages "关键词" --chat-ids oc_xxx
User
查群信息
chat get oc_xxx
User
查群成员
chat member list oc_xxx
User
改群名/群主
chat update oc_xxx --name "新名"
User
加/删群成员
chat member add/remove oc_xxx --id-list xxx
User
查消息详情
msg get om_xxx
User
看置顶消息
msg pins --chat-id oc_xxx
User
置顶/取消置顶
msg pin/unpin <message_id>
User
添加 Reaction
msg reaction add <message_id> --emoji-type THUMBSUP
User
删除消息
msg delete <message_id>
User
查消息已读
msg read-users om_xxx
App(仅 bot 消息)
创建群聊
chat create --name "群名"
App
获取群链接
chat link oc_xxx
App
标记 User 的命令必须先
auth login
,未登录会报错。标记 App 的命令使用应用身份,无需登录。

User IntentCommandToken
View recent messages of a group
msg history --container-id oc_xxx --container-id-type chat
User
View thread replies of a topic group
msg history --container-id omt_xxx --container-id-type thread
User
View chat with someone
search messages " " --chat-type p2p_chat --from-ids ou_xxx
User
Search group chats
msg search-chats --query "keywords"
User
Search messages within a group
search messages "keywords" --chat-ids oc_xxx
User
Check group information
chat get oc_xxx
User
Check group members
chat member list oc_xxx
User
Change group name/owner
chat update oc_xxx --name "new name"
User
Add/remove group members
chat member add/remove oc_xxx --id-list xxx
User
Check message details
msg get om_xxx
User
View pinned messages
msg pins --chat-id oc_xxx
User
Pin/unpin message
msg pin/unpin <message_id>
User
Add Reaction
msg reaction add <message_id> --emoji-type THUMBSUP
User
Delete message
msg delete <message_id>
User
Check message read status
msg read-users om_xxx
App (only bot messages)
Create group chat
chat create --name "group name"
App
Get group link
chat link oc_xxx
App
Commands marked User must be preceded by
auth login
, an error will be reported if not logged in. Commands marked App use application identity, no login required.

处理大量消息的最佳实践

Best Practices for Handling Large Volumes of Messages

当需要获取并分析大量消息(如 100+ 条)时:
  1. 保存到文件:每页结果用
    -o json
    输出,重定向到文件
  2. 循环翻页:检查
    HasMore
    PageToken
    ,循环获取直到满足条件
  3. 用 Python 解析:JSON 消息结构需要解析
    body.content
    提取文本
  4. 注意限频:搜索 API 有频率限制,大量请求间加 1s 延迟;
    msg history
    限频较宽松,可安全并发
  5. 时间戳
    create_time
    是毫秒级时间戳,需除以 1000 转为秒
  6. 话题群并发获取线程:话题群需要对每个
    thread_id
    单独调用
    msg history --container-id-type thread
    ,建议并行调用多个话题以提高效率(实测 10-20 个并发无问题)
  7. 已撤回消息
    deleted: true
    的消息内容为
    "This message was recalled"
    ,汇总时应跳过
python
import json
from datetime import datetime
When you need to retrieve and analyze a large number of messages (e.g., 100+):
  1. Save to File: Output each page result with
    -o json
    and redirect to a file
  2. Loop Pagination: Check
    HasMore
    and
    PageToken
    , loop retrieval until conditions are met
  3. Parse with Python: The JSON message structure requires parsing
    body.content
    to extract text
  4. Pay Attention to Rate Limits: The Search API has frequency limits, add a 1s delay between large numbers of requests;
    msg history
    has looser rate limits, concurrent calls are safe
  5. Timestamp:
    create_time
    is a millisecond timestamp, divide by 1000 to convert to seconds
  6. Concurrent Thread Retrieval for Topic Groups: Topic groups require separate calls to
    msg history --container-id-type thread
    for each
    thread_id
    , it is recommended to call multiple topics in parallel to improve efficiency (10-20 concurrent calls are tested to be problem-free)
  7. Recalled Messages: Messages with
    deleted: true
    have content
    "This message was recalled"
    , they should be skipped during summarization
python
import json
from datetime import datetime

解析消息时间

Parse message time

ts = int(msg['create_time']) / 1000 dt = datetime.fromtimestamp(ts) time_str = dt.strftime('%Y-%m-%d %H:%M')
ts = int(msg['create_time']) / 1000 dt = datetime.fromtimestamp(ts) time_str = dt.strftime('%Y-%m-%d %H:%M')

提取文本内容

Extract text content

content = json.loads(msg['body']['content']) text = content.get('text', '')

---
content = json.loads(msg['body']['content']) text = content.get('text', '')

---

权限要求

Permission Requirements

scope说明对应命令
im:message:readonly
消息读取msg get/history/list
im:message.group_msg:get_as_user
User 身份读取群消息msg history/list(读群消息必需)
im:message.pins
消息置顶管理msg pin/unpin/pins
im:message.reactions
消息 Reactionmsg reaction add/remove/list
im:message
消息读写msg delete
im:chat:read
群聊搜索msg search-chats
im:chat:readonly
群聊信息只读chat get、chat member list
im:chat.members:read
群成员读取chat member list
im:chat
群聊管理chat update/delete
im:chat.members
群成员管理chat member add/remove
search:message
消息搜索search messages

scopeDescriptionCorresponding Commands
im:message:readonly
Message readingmsg get/history/list
im:message.group_msg:get_as_user
Read group messages as User identitymsg history/list (required for reading group messages)
im:message.pins
Message pin managementmsg pin/unpin/pins
im:message.reactions
Message Reactionmsg reaction add/remove/list
im:message
Message read/writemsg delete
im:chat:read
Group chat searchmsg search-chats
im:chat:readonly
Group chat information read-onlychat get, chat member list
im:chat.members:read
Group member readingchat member list
im:chat
Group chat managementchat update/delete
im:chat.members
Group member managementchat member add/remove
search:message
Message searchsearch messages

与其他技能的分工

Division of Labor with Other Skills

场景使用技能
浏览聊天记录、搜索群聊、群信息/成员管理、Reaction/Pin/删除/获取消息feishu-cli-chat(本技能)
发送消息、回复、转发/合并转发feishu-cli-msg
搜索文档/应用、高级消息搜索(多条件筛选)feishu-cli-search
表格、日历、任务、文件、知识库等其他模块feishu-cli-toolkit
OAuth 登录、Token 管理feishu-cli-auth
ScenarioSkill to Use
Browse chat history, search group chats, group information/member management, Reaction/Pin/delete/get messagesfeishu-cli-chat (this skill)
Send messages, reply, forward/merge forwardfeishu-cli-msg
Search documents/apps, advanced message search (multi-condition filtering)feishu-cli-search
Sheets, calendar, tasks, files, knowledge base and other modulesfeishu-cli-toolkit
OAuth login, Token managementfeishu-cli-auth