messages
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMessages Skill
消息管理Skill
Retrieve chat message history, send messages, manage reactions, and search for chats/groups via the CLI.
lark通过 CLI检索聊天消息历史、发送消息、管理互动反应,以及搜索聊天/群组。
lark🤖 Capabilities and Use Cases
🤖 功能与适用场景
- Send markdown-lite messages with links and mentions
- Send images with and
--imageplacement{{image}} - Reply to messages and threads with /
--parent-id--root-id - Message recall/delete for cleanup
- Add/list/remove emoji reactions
- Browse emoji catalog reference
- Read chat history (chat or thread)
- Download message resources (images/files/audio/video)
- Find chats by name or member
- Use clear, flag-based CLI with consistent JSON output
- 发送包含链接和提及的轻量markdown消息
- 使用参数和
--image占位符发送图片{{image}} - 通过/
--parent-id回复消息和话题组--root-id - 撤回/删除消息以清理会话
- 添加/列出/移除表情反应
- 查看表情目录参考
- 读取聊天历史(会话或话题组)
- 下载消息资源(图片/文件/音频/视频)
- 通过名称或成员查找聊天会话
- 使用清晰的基于标志的CLI,输出统一JSON格式
🚀 Quick Reference
🚀 快速参考
Send message:
bash
lark msg send --to user@example.com --text "Hello!"Reply in thread:
bash
lark msg send --to oc_12345 --parent-id om_abcdef --msg-type text --text "Replying here"Read messages:
bash
lark msg history --chat-id oc_12345 --limit 10Find chats:
bash
lark chat search "project team"React / list / remove reaction:
bash
lark msg react --message-id om_123456789abcdef --reaction SMILE
lark msg react list --message-id om_123456789abcdef
lark msg react remove --message-id om_123456789abcdef --reaction-id ZCaCIjUBVVWSrm5L-3ZTw...Download resource:
bash
lark msg resource --message-id om_xxx --file-key img_v3_xxx --type image --output ./image.png发送消息:
bash
lark msg send --to user@example.com --text "Hello!"在话题组中回复:
bash
lark msg send --to oc_12345 --parent-id om_abcdef --msg-type text --text "Replying here"读取消息:
bash
lark msg history --chat-id oc_12345 --limit 10查找聊天会话:
bash
lark chat search "project team"添加/列出/移除反应:
bash
lark msg react --message-id om_123456789abcdef --reaction SMILE
lark msg react list --message-id om_123456789abcdef
lark msg react remove --message-id om_123456789abcdef --reaction-id ZCaCIjUBVVWSrm5L-3ZTw...下载资源:
bash
lark msg resource --message-id om_xxx --file-key img_v3_xxx --type image --output ./image.pngRunning Commands
运行命令
Ensure is in your PATH, or use the full path to the binary. Set the config directory if not using the default:
larkbash
lark msg <command>
lark chat <command>确保已在你的PATH中,或使用二进制文件的完整路径。若不使用默认配置目录,可设置配置目录:
larkbash
lark msg <command>
lark chat <command>Or with explicit config:
或指定配置目录:
LARK_CONFIG_DIR=/path/to/.lark lark msg <command>
undefinedLARK_CONFIG_DIR=/path/to/.lark lark msg <command>
undefinedCommands Reference
命令参考
Search for Chats/Groups
搜索聊天/群组
bash
lark chat search "project" --limit 10Available flags:
- : Maximum number of chats to retrieve (0 = no limit)
--limit
Output fields include:
- with
chats[],chat_id,name,description,owner_id,externalchat_status - ,
countquery
bash
lark chat search "project" --limit 10可用标志:
- : 要检索的最大聊天会话数量(0表示无限制)
--limit
输出字段包括:
- ,包含
chats[]、chat_id、name、description、owner_id、externalchat_status - 、
countquery
Send Messages
发送消息
Send messages to users or group chats as the bot.
bash
lark msg send --to ou_xxxx --text "Hello!"Reply in thread:
bash
lark msg send --to oc_xxxx --parent-id om_xxxx --msg-type text --text "Replying here"Available flags:
- (required): Recipient identifier (user ID, open_id, email, or chat_id)
--to - : Explicitly specify ID type (
--to-type,open_id,user_id,email) - auto-detected if omittedchat_id - : Message text content (markdown-lite). Use
--textto place images.{{image}} - : Image file path (repeatable)
--image - : Message type:
--msg-type(default) orposttext - : Parent message ID to reply in thread (optional)
--parent-id - : Root message ID for thread replies (optional)
--root-id
Output:
json
{
"success": true,
"message_id": "om_dc13264520392913993dd051dba21dcf",
"chat_id": "oc_xxxxx",
"create_time": "2026-01-14T10:30:00+08:00"
}以机器人身份向用户或群聊发送消息。
bash
lark msg send --to ou_xxxx --text "Hello!"在话题组中回复:
bash
lark msg send --to oc_xxxx --parent-id om_xxxx --msg-type text --text "Replying here"可用标志:
- (必填): 接收者标识(用户ID、open_id、邮箱或chat_id)
--to - : 明确指定ID类型(
--to-type、open_id、user_id、email)——若省略则自动检测chat_id - : 消息文本内容(轻量markdown格式)。使用
--text放置图片。{{image}} - : 图片文件路径(可重复使用)
--image - : 消息类型:
--msg-type(默认)或posttext - : 要回复的父消息ID(可选,用于话题组回复)
--parent-id - : 话题组回复的根消息ID(可选)
--root-id
输出:
json
{
"success": true,
"message_id": "om_dc13264520392913993dd051dba21dcf",
"chat_id": "oc_xxxxx",
"create_time": "2026-01-14T10:30:00+08:00"
}Get Chat History
获取聊天历史
bash
lark msg history --chat-id oc_xxxxx --limit 50 --sort descAvailable flags:
- (required): Chat ID or thread ID
--chat-id - : Container type -
--type(default) orchatthread - : Start time (Unix timestamp or ISO 8601)
--start - : End time (Unix timestamp or ISO 8601)
--end - : Sort order -
--sort(default) orascdesc - : Maximum number of messages (0 = no limit)
--limit
Output fields include:
- with
messages[],message_id,msg_type,content,sender,create_time,mentions,is_reply,thread_iddeleted - ,
countchat_id
bash
lark msg history --chat-id oc_xxxxx --limit 50 --sort desc可用标志:
- (必填): 聊天ID或话题组ID
--chat-id - : 容器类型——
--type(默认)或chatthread - : 开始时间(Unix时间戳或ISO 8601格式)
--start - : 结束时间(Unix时间戳或ISO 8601格式)
--end - : 排序顺序——
--sort(默认)或ascdesc - : 最大消息数量(0表示无限制)
--limit
输出字段包括:
- ,包含
messages[]、message_id、msg_type、content、sender、create_time、mentions、is_reply、thread_iddeleted - 、
countchat_id
React to Message
给消息添加反应
Add a reaction to a message as the bot.
bash
lark msg react --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILEAvailable flags:
- (required): Message ID to react to
--message-id - (required): Reaction ID or emoji name
--reaction - : Reaction type (default:
--type)emoji
Output:
json
{
"success": true,
"message_id": "om_dc13264520392913993dd051dba21dcf",
"reaction_type": "emoji",
"reaction_id": "ZCaCIjUBVVWSrm5L-3ZTw...",
"emoji_type": "SMILE"
}Notes:
- Reactions are added as the bot/app. The bot must be in the chat to react.
- Emoji types must match the Lark emoji catalog (e.g., ,
SMILE).LAUGH - Replies sent with are always created in a thread.
--parent-id
以机器人身份给消息添加反应。
bash
lark msg react --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE可用标志:
- (必填): 要添加反应的消息ID
--message-id - (必填): 反应ID或表情名称
--reaction - : 反应类型(默认:
--type)emoji
输出:
json
{
"success": true,
"message_id": "om_dc13264520392913993dd051dba21dcf",
"reaction_type": "emoji",
"reaction_id": "ZCaCIjUBVVWSrm5L-3ZTw...",
"emoji_type": "SMILE"
}注意事项:
- 反应以机器人/应用身份添加。机器人必须在聊天会话中才能添加反应。
- 表情类型必须匹配Lark表情目录(例如、
SMILE)。LAUGH - 使用发送的回复始终会创建在话题组中。
--parent-id
Emoji Catalog Reference
表情目录参考
bash
lark msg react emojisUse this command to list the supported emoji types for reactions.
Custom Emojis: Organization-specific custom emojis can be configured in :
.lark/config.yamlyaml
custom_emojis:
"7405453485858095136": "ez-pepe"Custom emoji IDs will appear in the field of the output.
custom_emojisbash
lark msg react emojis使用此命令列出支持的反应表情类型。
自定义表情: 组织专属的自定义表情可在中配置:
.lark/config.yamlyaml
custom_emojis:
"7405453485858095136": "ez-pepe"自定义表情ID会出现在输出的字段中。
custom_emojisList Message Reactions
列出消息反应
bash
lark msg react list --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE --limit 50Available flags:
- (required): Message ID to list reactions for
--message-id - : Emoji type filter (e.g.,
--reaction)SMILE - : Maximum number of reactions to retrieve (0 = no limit)
--limit
Output fields include:
- ,
message_id,reactions[]count
bash
lark msg react list --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE --limit 50可用标志:
- (必填): 要列出反应的消息ID
--message-id - : 表情类型过滤器(例如
--reaction)SMILE - : 要检索的最大反应数量(0表示无限制)
--limit
输出字段包括:
- 、
message_id、reactions[]count
Remove Message Reaction
移除消息反应
bash
lark msg react remove --message-id om_dc13264520392913993dd051dba21dcf --reaction-id ZCaCIjUBVVWSrm5L-3ZTw...Available flags:
- (required): Message ID to remove reaction from
--message-id - (required): Reaction ID to remove
--reaction-id
Output fields include:
- ,
success,message_id,reaction_type,reaction_idemoji_type
bash
lark msg react remove --message-id om_dc13264520392913993dd051dba21dcf --reaction-id ZCaCIjUBVVWSrm5L-3ZTw...可用标志:
- (必填): 要移除反应的消息ID
--message-id - (必填): 要移除的反应ID
--reaction-id
输出字段包括:
- 、
success、message_id、reaction_type、reaction_idemoji_type
Recall Messages
撤回消息
Recall/delete previously sent messages from chats.
bash
lark msg recall om_dc13264520392913993dd051dba21dcfOutput fields include:
- ,
successmessage_id
从聊天会话中撤回/删除已发送的消息。
bash
lark msg recall om_dc13264520392913993dd051dba21dcf输出字段包括:
- 、
successmessage_id
Downloading Resource Files
下载资源文件
Download images, files, audio, and video from messages using :
msg resourcebash
lark msg resource --message-id om_xxx --file-key img_v3_xxx --type image --output ./image.png
lark msg resource --message-id om_xxx --file-key file_v2_xxx --type file --output ./document.pdfAvailable flags:
- (required): Message ID containing the resource
--message-id - (required): Resource key from message content (
--file-keyorimage_key)file_key - (required):
--typefor images,imagefor files/audio/videofile - (required): Output file path
--output
Output fields include:
- ,
success,message_id,file_key,output_path,content_typebytes_written
Limitations:
- Maximum file size: 100MB
- Emoji resources cannot be downloaded
- Resources from card, merged, or forwarded messages are not supported
- The and
message_idmust matchfile_key
使用从消息中下载图片、文件、音频和视频:
msg resourcebash
lark msg resource --message-id om_xxx --file-key img_v3_xxx --type image --output ./image.png
lark msg resource --message-id om_xxx --file-key file_v2_xxx --type file --output ./document.pdf可用标志:
- (必填): 包含资源的消息ID
--message-id - (必填): 消息内容中的资源密钥(
--file-key或image_key)file_key - (必填):
--type表示图片,image表示文件/音频/视频file - (必填): 输出文件路径
--output
输出字段包括:
- 、
success、message_id、file_key、output_path、content_typebytes_written
限制:
- 最大文件大小:100MB
- 无法下载表情资源
- 不支持卡片、合并或转发消息中的资源
- 和
message_id必须匹配file_key
Tips
小贴士
- Use for line breaks and
\nfor indentation in\t--text - Use to mention users in group chats
@{ou_xxx} - Use in text to place images in order
{{image}} - Chat IDs start with ; thread IDs start with
oc_orthread_omt_ - Use to discover
lark msg react listfor removalreaction_id - The CLI auto-detects recipient type; override with if needed
--to-type
- 在中使用
--text换行,\n缩进\t - 在群聊中使用提及用户
@{ou_xxx} - 在文本中使用按顺序放置图片
{{image}} - 聊天ID以开头;话题组ID以
oc_或thread_开头omt_ - 使用查找要移除的
lark msg react listreaction_id - CLI会自动检测接收者类型;若需要可使用覆盖
--to-type
Message Types
消息类型
- - Plain text message
text - - Rich text post
post - - Image
image - - File attachment
file - - Audio message
audio - - Video/media
media - - Sticker/emoji
sticker - - Interactive card
interactive - - Shared chat
share_chat - - Shared user contact
share_user
- - 纯文本消息
text - - 富文本帖子
post - - 图片
image - - 文件附件
file - - 音频消息
audio - - 视频/媒体
media - - 贴纸/表情
sticker - - 互动卡片
interactive - - 共享聊天
share_chat - - 共享用户联系人
share_user
Reading Thread Replies
读取话题组回复
If a message has a , it is part of a thread (or is the root). To fetch replies:
thread_idbash
lark msg history --chat-id oc_xxxxx --limit 10 --sort desc
lark msg history --chat-id omt_1a3b99f9d2cfd982 --type threadThread messages will have for replies (root message has ).
is_reply: trueis_reply: false如果消息包含,则它属于某个话题组(或是根消息)。要获取回复:
thread_idbash
lark msg history --chat-id oc_xxxxx --limit 10 --sort desc
lark msg history --chat-id omt_1a3b99f9d2cfd982 --type thread话题组消息中,回复的为(根消息的为)。
is_replytrueis_replyfalseOutput Format
输出格式
All commands output JSON.
所有命令均输出JSON格式。
Error Handling
错误处理
Errors return JSON:
json
{
"error": true,
"code": "ERROR_CODE",
"message": "Description"
}Common error codes:
- - Need to run
AUTH_ERRORlark auth login - - Missing messages permissions
SCOPE_ERROR - - Missing required fields (e.g., chat-id)
VALIDATION_ERROR - - Lark API issue (e.g., bot not in group, missing permissions)
API_ERROR
错误会返回JSON:
json
{
"error": true,
"code": "ERROR_CODE",
"message": "Description"
}常见错误代码:
- - 需要运行
AUTH_ERRORlark auth login - - 缺少消息权限
SCOPE_ERROR - - 缺少必填字段(例如chat-id)
VALIDATION_ERROR - - Lark API问题(例如机器人不在群组中、缺少权限)
API_ERROR
Required Permissions
必填权限
This skill requires the scope group. If you see a , add permissions:
messagesSCOPE_ERRORbash
lark auth login --add --scopes messagesTo check current permissions:
bash
lark auth statusAdditional requirements:
For reading messages:
- The bot must be in the group chat
- Group chat reads require the "Read all messages in associated group chat" permission
- Private chat reads require
im:message:readonly
For sending messages:
- Requires or
im:messageim:message:send_as_bot - The bot must be added to group chats before it can send messages to them
For reactions:
- List reactions requires
im:message.reactions:read - Add/remove reactions requires
im:message.reactions:write_only
此Skill需要权限组。若遇到,请添加权限:
messagesSCOPE_ERRORbash
lark auth login --add --scopes messages查看当前权限:
bash
lark auth status额外要求:
读取消息:
- 机器人必须在群聊中
- 群聊读取需要“读取关联群聊中的所有消息”权限
- 私聊读取需要权限
im:message:readonly
发送消息:
- 需要或
im:message权限im:message:send_as_bot - 机器人必须先被添加到群聊中才能向其发送消息
反应相关:
- 列出反应需要权限
im:message.reactions:read - 添加/移除反应需要权限
im:message.reactions:write_only
Notes
注意事项
- Messages are sent as the bot/app
- Messages are sorted by creation time ascending by default
- Time filters do not work for thread container type
- Message IDs typically start with
om_
- 消息以机器人/应用身份发送
- 消息默认按创建时间升序排序
- 时间过滤器对话题组容器类型无效
- 消息ID通常以开头
om_