messages

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Messages Skill

消息管理Skill

Retrieve chat message history, send messages, manage reactions, and search for chats/groups via the
lark
CLI.
通过
lark
CLI检索聊天消息历史、发送消息、管理互动反应,以及搜索聊天/群组。

🤖 Capabilities and Use Cases

🤖 功能与适用场景

  • Send markdown-lite messages with links and mentions
  • Send images with
    --image
    and
    {{image}}
    placement
  • 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 10
Find 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.png

Running Commands

运行命令

Ensure
lark
is in your PATH, or use the full path to the binary. Set the config directory if not using the default:
bash
lark msg <command>
lark chat <command>
确保
lark
已在你的PATH中,或使用二进制文件的完整路径。若不使用默认配置目录,可设置配置目录:
bash
lark msg <command>
lark chat <command>

Or with explicit config:

或指定配置目录:

LARK_CONFIG_DIR=/path/to/.lark lark msg <command>
undefined
LARK_CONFIG_DIR=/path/to/.lark lark msg <command>
undefined

Commands Reference

命令参考

Search for Chats/Groups

搜索聊天/群组

bash
lark chat search "project" --limit 10
Available flags:
  • --limit
    : Maximum number of chats to retrieve (0 = no limit)
Output fields include:
  • chats[]
    with
    chat_id
    ,
    name
    ,
    description
    ,
    owner_id
    ,
    external
    ,
    chat_status
  • count
    ,
    query
bash
lark chat search "project" --limit 10
可用标志:
  • --limit
    : 要检索的最大聊天会话数量(0表示无限制)
输出字段包括:
  • chats[]
    ,包含
    chat_id
    name
    description
    owner_id
    external
    chat_status
  • count
    query

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:
  • --to
    (required): Recipient identifier (user ID, open_id, email, or chat_id)
  • --to-type
    : Explicitly specify ID type (
    open_id
    ,
    user_id
    ,
    email
    ,
    chat_id
    ) - auto-detected if omitted
  • --text
    : Message text content (markdown-lite). Use
    {{image}}
    to place images.
  • --image
    : Image file path (repeatable)
  • --msg-type
    : Message type:
    post
    (default) or
    text
  • --parent-id
    : Parent message ID to reply in thread (optional)
  • --root-id
    : Root message ID for thread replies (optional)
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"
可用标志:
  • --to
    (必填): 接收者标识(用户ID、open_id、邮箱或chat_id)
  • --to-type
    : 明确指定ID类型(
    open_id
    user_id
    email
    chat_id
    )——若省略则自动检测
  • --text
    : 消息文本内容(轻量markdown格式)。使用
    {{image}}
    放置图片。
  • --image
    : 图片文件路径(可重复使用)
  • --msg-type
    : 消息类型:
    post
    (默认)或
    text
  • --parent-id
    : 要回复的父消息ID(可选,用于话题组回复)
  • --root-id
    : 话题组回复的根消息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 desc
Available flags:
  • --chat-id
    (required): Chat ID or thread ID
  • --type
    : Container type -
    chat
    (default) or
    thread
  • --start
    : Start time (Unix timestamp or ISO 8601)
  • --end
    : End time (Unix timestamp or ISO 8601)
  • --sort
    : Sort order -
    asc
    (default) or
    desc
  • --limit
    : Maximum number of messages (0 = no limit)
Output fields include:
  • messages[]
    with
    message_id
    ,
    msg_type
    ,
    content
    ,
    sender
    ,
    create_time
    ,
    mentions
    ,
    is_reply
    ,
    thread_id
    ,
    deleted
  • count
    ,
    chat_id
bash
lark msg history --chat-id oc_xxxxx --limit 50 --sort desc
可用标志:
  • --chat-id
    (必填): 聊天ID或话题组ID
  • --type
    : 容器类型——
    chat
    (默认)或
    thread
  • --start
    : 开始时间(Unix时间戳或ISO 8601格式)
  • --end
    : 结束时间(Unix时间戳或ISO 8601格式)
  • --sort
    : 排序顺序——
    asc
    (默认)或
    desc
  • --limit
    : 最大消息数量(0表示无限制)
输出字段包括:
  • messages[]
    ,包含
    message_id
    msg_type
    content
    sender
    create_time
    mentions
    is_reply
    thread_id
    deleted
  • count
    chat_id

React to Message

给消息添加反应

Add a reaction to a message as the bot.
bash
lark msg react --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE
Available flags:
  • --message-id
    (required): Message ID to react to
  • --reaction
    (required): Reaction ID or emoji name
  • --type
    : Reaction type (default:
    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
    --parent-id
    are always created in a thread.
以机器人身份给消息添加反应。
bash
lark msg react --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE
可用标志:
  • --message-id
    (必填): 要添加反应的消息ID
  • --reaction
    (必填): 反应ID或表情名称
  • --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 emojis
Use this command to list the supported emoji types for reactions.
Custom Emojis: Organization-specific custom emojis can be configured in
.lark/config.yaml
:
yaml
custom_emojis:
  "7405453485858095136": "ez-pepe"
Custom emoji IDs will appear in the
custom_emojis
field of the output.
bash
lark msg react emojis
使用此命令列出支持的反应表情类型。
自定义表情: 组织专属的自定义表情可在
.lark/config.yaml
中配置:
yaml
custom_emojis:
  "7405453485858095136": "ez-pepe"
自定义表情ID会出现在输出的
custom_emojis
字段中。

List Message Reactions

列出消息反应

bash
lark msg react list --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE --limit 50
Available flags:
  • --message-id
    (required): Message ID to list reactions for
  • --reaction
    : Emoji type filter (e.g.,
    SMILE
    )
  • --limit
    : Maximum number of reactions to retrieve (0 = no limit)
Output fields include:
  • message_id
    ,
    reactions[]
    ,
    count
bash
lark msg react list --message-id om_dc13264520392913993dd051dba21dcf --reaction SMILE --limit 50
可用标志:
  • --message-id
    (必填): 要列出反应的消息ID
  • --reaction
    : 表情类型过滤器(例如
    SMILE
  • --limit
    : 要检索的最大反应数量(0表示无限制)
输出字段包括:
  • message_id
    reactions[]
    count

Remove Message Reaction

移除消息反应

bash
lark msg react remove --message-id om_dc13264520392913993dd051dba21dcf --reaction-id ZCaCIjUBVVWSrm5L-3ZTw...
Available flags:
  • --message-id
    (required): Message ID to remove reaction from
  • --reaction-id
    (required): Reaction ID to remove
Output fields include:
  • success
    ,
    message_id
    ,
    reaction_type
    ,
    reaction_id
    ,
    emoji_type
bash
lark msg react remove --message-id om_dc13264520392913993dd051dba21dcf --reaction-id ZCaCIjUBVVWSrm5L-3ZTw...
可用标志:
  • --message-id
    (必填): 要移除反应的消息ID
  • --reaction-id
    (必填): 要移除的反应ID
输出字段包括:
  • success
    message_id
    reaction_type
    reaction_id
    emoji_type

Recall Messages

撤回消息

Recall/delete previously sent messages from chats.
bash
lark msg recall om_dc13264520392913993dd051dba21dcf
Output fields include:
  • success
    ,
    message_id
从聊天会话中撤回/删除已发送的消息。
bash
lark msg recall om_dc13264520392913993dd051dba21dcf
输出字段包括:
  • success
    message_id

Downloading Resource Files

下载资源文件

Download images, files, audio, and video from messages using
msg resource
:
bash
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
Available flags:
  • --message-id
    (required): Message ID containing the resource
  • --file-key
    (required): Resource key from message content (
    image_key
    or
    file_key
    )
  • --type
    (required):
    image
    for images,
    file
    for files/audio/video
  • --output
    (required): Output file path
Output fields include:
  • success
    ,
    message_id
    ,
    file_key
    ,
    output_path
    ,
    content_type
    ,
    bytes_written
Limitations:
  • Maximum file size: 100MB
  • Emoji resources cannot be downloaded
  • Resources from card, merged, or forwarded messages are not supported
  • The
    message_id
    and
    file_key
    must match
使用
msg resource
从消息中下载图片、文件、音频和视频:
bash
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
可用标志:
  • --message-id
    (必填): 包含资源的消息ID
  • --file-key
    (必填): 消息内容中的资源密钥(
    image_key
    file_key
  • --type
    (必填):
    image
    表示图片,
    file
    表示文件/音频/视频
  • --output
    (必填): 输出文件路径
输出字段包括:
  • success
    message_id
    file_key
    output_path
    content_type
    bytes_written
限制:
  • 最大文件大小:100MB
  • 无法下载表情资源
  • 不支持卡片、合并或转发消息中的资源
  • message_id
    file_key
    必须匹配

Tips

小贴士

  • Use
    \n
    for line breaks and
    \t
    for indentation in
    --text
  • Use
    @{ou_xxx}
    to mention users in group chats
  • Use
    {{image}}
    in text to place images in order
  • Chat IDs start with
    oc_
    ; thread IDs start with
    thread_
    or
    omt_
  • Use
    lark msg react list
    to discover
    reaction_id
    for removal
  • The CLI auto-detects recipient type; override with
    --to-type
    if needed
  • --text
    中使用
    \n
    换行,
    \t
    缩进
  • 在群聊中使用
    @{ou_xxx}
    提及用户
  • 在文本中使用
    {{image}}
    按顺序放置图片
  • 聊天ID以
    oc_
    开头;话题组ID以
    thread_
    omt_
    开头
  • 使用
    lark msg react list
    查找要移除的
    reaction_id
  • CLI会自动检测接收者类型;若需要可使用
    --to-type
    覆盖

Message Types

消息类型

  • text
    - Plain text message
  • post
    - Rich text post
  • image
    - Image
  • file
    - File attachment
  • audio
    - Audio message
  • media
    - Video/media
  • sticker
    - Sticker/emoji
  • interactive
    - Interactive card
  • share_chat
    - Shared chat
  • share_user
    - Shared user contact
  • text
    - 纯文本消息
  • post
    - 富文本帖子
  • image
    - 图片
  • file
    - 文件附件
  • audio
    - 音频消息
  • media
    - 视频/媒体
  • sticker
    - 贴纸/表情
  • interactive
    - 互动卡片
  • share_chat
    - 共享聊天
  • share_user
    - 共享用户联系人

Reading Thread Replies

读取话题组回复

If a message has a
thread_id
, it is part of a thread (or is the root). To fetch replies:
bash
lark msg history --chat-id oc_xxxxx --limit 10 --sort desc
lark msg history --chat-id omt_1a3b99f9d2cfd982 --type thread
Thread messages will have
is_reply: true
for replies (root message has
is_reply: false
).
如果消息包含
thread_id
,则它属于某个话题组(或是根消息)。要获取回复:
bash
lark msg history --chat-id oc_xxxxx --limit 10 --sort desc
lark msg history --chat-id omt_1a3b99f9d2cfd982 --type thread
话题组消息中,回复的
is_reply
true
(根消息的
is_reply
false
)。

Output Format

输出格式

All commands output JSON.
所有命令均输出JSON格式。

Error Handling

错误处理

Errors return JSON:
json
{
  "error": true,
  "code": "ERROR_CODE",
  "message": "Description"
}
Common error codes:
  • AUTH_ERROR
    - Need to run
    lark auth login
  • SCOPE_ERROR
    - Missing messages permissions
  • VALIDATION_ERROR
    - Missing required fields (e.g., chat-id)
  • API_ERROR
    - Lark API issue (e.g., bot not in group, missing permissions)
错误会返回JSON:
json
{
  "error": true,
  "code": "ERROR_CODE",
  "message": "Description"
}
常见错误代码:
  • AUTH_ERROR
    - 需要运行
    lark auth login
  • SCOPE_ERROR
    - 缺少消息权限
  • VALIDATION_ERROR
    - 缺少必填字段(例如chat-id)
  • API_ERROR
    - Lark API问题(例如机器人不在群组中、缺少权限)

Required Permissions

必填权限

This skill requires the
messages
scope group. If you see a
SCOPE_ERROR
, add permissions:
bash
lark auth login --add --scopes messages
To check current permissions:
bash
lark auth status
Additional 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
    im:message
    or
    im: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需要
messages
权限组。若遇到
SCOPE_ERROR
,请添加权限:
bash
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_
    开头