feishu-cli-msg

Original🇨🇳 Chinese
Translated

Full-featured Feishu message management. Send messages (11 types including text/post/interactive cards), reply to messages, forward/merge forward messages, add/remove Reaction emojis, pin messages, delete messages, view message details, check conversation history, and search group chats. Use this when users request "send message", "reply", "forward", "pin", "Reaction", "emoji response", "message history", or "pin message".

11installs
Added on

NPX Install

npx skill4agent add riba2534/feishu-cli feishu-cli-msg

SKILL.md Content (Chinese)

View Translation Comparison →

Feishu Message Sending Skill

Send Feishu messages via feishu-cli, supporting multiple message types and rich message management operations.

Core Concepts

Message Architecture

The
content
field of Feishu Message API is a JSON string (not a JSON object). The CLI provides three input methods:
Input MethodParameterApplicable Scenario
Quick Text
--text "content"
Plain text messages, the simplest option
Inline JSON
--content '{"key":"val"}'
or
-c
Simple JSON, can be done in one line
JSON File
--content-file file.json
Complex messages (cards, rich text, etc.)
Priority:
--text
>
--content
>
--content-file
(the former takes precedence when specified simultaneously)

Recipient Types

--receive-id-typeDescriptionExample
emailEmail addressuser@example.com
open_idOpen IDou_xxx
user_idUser IDxxx
union_idUnion IDon_xxx
chat_idGroup Chat IDoc_xxx

Message Type Selection

Decision Tree (Automatically selected when Claude doesn't specify type)

Default priority is
interactive
(card message)
with beautiful styling, rich content, and support for colors/multi-columns/buttons, etc.
User Requirement
├─ [Default] Notification/Report/Alert/Any informative message → interactive (card)
├─ Send uploaded image/file/audio/video → image/file/audio/media
├─ Share group chat or user business card → share_chat/share_user
├─ Conversation divider (p2p only) → system
└─ Use text/post only in the following scenarios:
   ├─ User explicitly requests plain text → text
   └─ User explicitly requests rich text → post
Why prioritize cards: text does not support any format rendering, post has limited styling, while cards support colored headers, multi-column fields, buttons, dividers, notes, etc., with visual effects far superior to other types.

Overview of Message Types

TypeDescriptioncontent FormatSize Limit
textPlain text
{"text":"content"}
150 KB
postRich text
{"zh_cn":{"title":"","content":[[...]]}}
150 KB
imageImage
{"image_key":"img_xxx"}
fileFile
{"file_key":"file_v2_xxx"}
audioVoice
{"file_key":"file_v2_xxx"}
mediaVideo
{"file_key":"...","image_key":"..."}
stickerSticker
{"file_key":"file_v2_xxx"}
Forward only
interactiveCardCard JSON / template_id / card_id30 KB
share_chatGroup Chat Card
{"chat_id":"oc_xxx"}
share_userUser Business Card
{"user_id":"ou_xxx"}
systemSystem Divider
{"type":"divider",...}
P2P only

Sending Commands

Basic Format

bash
feishu-cli msg send \
  --receive-id-type <type> \
  --receive-id <id> \
  [--msg-type <msg_type>] \
  [--text "<text>" | --content '<json>' | --content-file <file.json>]

text Type

bash
# Simplest form (default msg-type is text)
feishu-cli msg send \
  --receive-id-type email \
  --receive-id user@example.com \
  --text "Hello, this is a test message"
Inline syntax supported by text type:
  • @
    user:
    <at user_id="ou_xxx">Tom</at>
  • @
    all users:
    <at user_id="all"></at>
Note: text type does not support rich text styles (bold, italic, underline, strikethrough, hyperlinks, etc. will not be rendered). For formatted layout, use the
post
type.

post Type (Rich Text)

It is recommended to use the
md
tag to carry Markdown, with one
md
tag occupying one paragraph:
bash
cat > /tmp/msg.json << 'EOF'
{
  "zh_cn": {
    "title": "Project Progress Notification",
    "content": [
      [{"tag": "md", "text": "**This Week's Progress**\n- Completed Feature A development\n- Fixed 3 Bugs\n- [View Details](https://example.com)"}],
      [{"tag": "md", "text": "**Next Week's Plan**\n1. Feature B development\n2. Performance optimization"}]
    ]
  }
}
EOF

feishu-cli msg send \
  --receive-id-type email \
  --receive-id user@example.com \
  --msg-type post \
  --content-file /tmp/msg.json
Tag types supported by post:
tagDescriptionMain Attributes
textTexttext, style (bold/italic/underline/lineThrough)
aHyperlinktext, href
at@useruser_id, user_name
imgImageimage_key, width, height
mediaVideofile_key, image_key
emotionEmojiemoji_type
hrDivider
code_blockCode Blocklanguage, text
mdMarkdowntext (occupies a single paragraph, recommended)

interactive Type (Card Message)

There are three ways to send card messages:
Method 1: Complete Card JSON (Recommended, most flexible)
bash
cat > /tmp/card.json << 'EOF'
{
  "header": {
    "template": "blue",
    "title": {"tag": "plain_text", "content": "Task Completion Notification"}
  },
  "elements": [
    {"tag": "markdown", "content": "**Project**: feishu-cli\n**Status**: Completed\n**Responsible Person**: <at id=all></at>"},
    {"tag": "hr"},
    {"tag": "note", "elements": [{"tag": "plain_text", "content": "Automatically sent by CI/CD"}]}
  ]
}
EOF

feishu-cli msg send \
  --receive-id-type email \
  --receive-id user@example.com \
  --msg-type interactive \
  --content-file /tmp/card.json
Method 2: template_id
bash
cat > /tmp/card.json << 'EOF'
{
  "type": "template",
  "data": {
    "template_id": "AAqk1xxxxxx",
    "template_variable": {"name": "Zhang San", "status": "Completed"}
  }
}
EOF

feishu-cli msg send \
  --receive-id-type email \
  --receive-id user@example.com \
  --msg-type interactive \
  --content-file /tmp/card.json
Method 3: card_id
bash
feishu-cli msg send \
  --receive-id-type email \
  --receive-id user@example.com \
  --msg-type interactive \
  --content '{"type":"card","data":{"card_id":"7371713483664506900"}}'

Card JSON Structure (v1 vs v2)

v1 Format (Recommended, good compatibility):
json
{
  "header": {"template": "blue", "title": {"tag": "plain_text", "content": "Title"}},
  "elements": [...]
}
v2 Format (More components):
json
{
  "schema": "2.0",
  "header": {"template": "blue", "title": {"tag": "plain_text", "content": "Title"}},
  "body": {"direction": "vertical", "elements": [...]}
}
v2 additionally supports advanced components such as table, chart, form_container, column_set (multi-column layout), etc. For simple notifications, v1 is sufficient; use v2 when complex layouts are needed.

Header Color Templates

Color ValueColor SystemRecommended Scenario
blueBlueGeneral notifications, information
wathetLight BlueLightweight prompts
turquoiseCyanIn-progress status
greenGreenSuccess, completion
yellowYellowNotes, reminders
orangeOrangeWarnings
redRedErrors, emergencies
carmineDeep RedSevere alerts
violetVioletSpecial markers
purplePurpleCustom categories
indigoIndigoDark theme
greyGreyProcessed, archived
Semantic Recommendations: Green = Success / Blue = Notification / Orange = Warning / Red = Error / Grey = Processed

Quick Reference for Common Components

Content Components:
ComponenttagDescription
Markdown
markdown
Supports lark_md syntax, most commonly used
Divider
hr
Horizontal divider
Note
note
Bottom gray small text note
Image
img
Image display
Layout Components:
ComponenttagDescription
Text + Attachment
div
Text block, can contain fields (multi-column) and extra (right attachment)
Multi-column Layout
column_set
(v2)
Horizontal column layout
Interactive Components:
ComponenttagDescription
Button
button
Three types: default/primary/danger
Dropdown Selection
select_static
Static dropdown menu
Date Picker
date_picker
Date picker
Collapsible Menu
overflow
More operations menu

Card Markdown Syntax (lark_md)

The
markdown
component in cards uses
lark_md
syntax, which differs from standard Markdown:
markdown
# Supported Syntax
**bold** *italic* ~~strikethrough~~ [link](url) `inline code`
![image](img_v2_xxx)

# Unique Syntax
<font color='green'>Green text</font>
<font color='red'>Red text</font>
<font color='grey'>Grey text</font>
<at id=ou_xxx></at>
<at id=all></at>
Note:
<font color>
in lark_md only supports three colors: green/red/grey.

Common Card Templates

Template 1: Simple Notification Card

json
{
  "header": {
    "template": "blue",
    "title": {"tag": "plain_text", "content": "Notification Title"}
  },
  "elements": [
    {"tag": "markdown", "content": "Notification content, supports **bold** and [links](https://example.com)"},
    {"tag": "note", "elements": [{"tag": "plain_text", "content": "From automation tool"}]}
  ]
}

Template 2: Alert Card (Multi-column + Buttons)

json
{
  "header": {
    "template": "red",
    "title": {"tag": "plain_text", "content": "Alert Notification"}
  },
  "elements": [
    {
      "tag": "div",
      "fields": [
        {"is_short": true, "text": {"tag": "lark_md", "content": "**Service**\napi-gateway"}},
        {"is_short": true, "text": {"tag": "lark_md", "content": "**Level**\n<font color='red'>P0</font>"}},
        {"is_short": true, "text": {"tag": "lark_md", "content": "**Time**\n2024-01-01 10:00"}},
        {"is_short": true, "text": {"tag": "lark_md", "content": "**Impact**\n<font color='red'>Users cannot log in</font>"}}
      ]
    },
    {"tag": "hr"},
    {
      "tag": "action",
      "actions": [
        {"tag": "button", "text": {"tag": "plain_text", "content": "View Details"}, "type": "primary", "url": "https://example.com/alert/123"},
        {"tag": "button", "text": {"tag": "plain_text", "content": "Ignore"}, "type": "default"}
      ]
    }
  ]
}

Template 3: Progress Report Card

json
{
  "header": {
    "template": "green",
    "title": {"tag": "plain_text", "content": "Build Report"}
  },
  "elements": [
    {"tag": "markdown", "content": "**Project**: feishu-cli\n**Branch**: main\n**Commit**: abc1234"},
    {"tag": "hr"},
    {"tag": "markdown", "content": "<font color='green'>Tests: 42/42 passed</font>\n<font color='green'>Build: Success</font>\n<font color='grey'>Duration: 3m 25s</font>"},
    {"tag": "hr"},
    {
      "tag": "action",
      "actions": [
        {"tag": "button", "text": {"tag": "plain_text", "content": "View Logs"}, "type": "default", "url": "https://ci.example.com/build/123"}
      ]
    },
    {"tag": "note", "elements": [{"tag": "plain_text", "content": "CI/CD Pipeline #123"}]}
  ]
}

Template 4: Document Operation Notification

json
{
  "header": {
    "template": "turquoise",
    "title": {"tag": "plain_text", "content": "Document Operation Notification"}
  },
  "elements": [
    {
      "tag": "div",
      "fields": [
        {"is_short": true, "text": {"tag": "lark_md", "content": "**Operation Type**\nCreate Document"}},
        {"is_short": true, "text": {"tag": "lark_md", "content": "**Status**\n<font color='green'>Success</font>"}}
      ]
    },
    {"tag": "markdown", "content": "**Document Title**: Weekly Report 2024-W01\n**Document Link**: [Click to View](https://xxx.feishu.cn/docx/abc123)"},
    {"tag": "note", "elements": [{"tag": "plain_text", "content": "Automatically created by feishu-cli"}]}
  ]
}

Template 5: Approval Confirmation Card (Multiple Buttons)

json
{
  "header": {
    "template": "orange",
    "title": {"tag": "plain_text", "content": "Approval Request"}
  },
  "elements": [
    {"tag": "markdown", "content": "**Applicant**: Zhang San\n**Application Type**: Server Expansion\n**Description**: Online traffic has increased, need to add 2 servers"},
    {"tag": "hr"},
    {
      "tag": "action",
      "actions": [
        {"tag": "button", "text": {"tag": "plain_text", "content": "Approve"}, "type": "primary"},
        {"tag": "button", "text": {"tag": "plain_text", "content": "Reject"}, "type": "danger"},
        {"tag": "button", "text": {"tag": "plain_text", "content": "View Details"}, "type": "default", "url": "https://example.com/approval/456"}
      ]
    }
  ]
}

Reply to Messages

Reply to specified messages, supporting the same message types and input methods as
msg send
.
bash
# Text reply
feishu-cli msg reply <message_id> --text "Received, I will handle it"

# Card reply
feishu-cli msg reply <message_id> --msg-type interactive --content-file /tmp/card.json

# Rich text reply
feishu-cli msg reply <message_id> --msg-type post --content-file /tmp/post.json
ParameterDescriptionDefault Value
--msg-type
Message type
text
--text
/
--content
/
--content-file
Message content (choose one of three)Required

Merge Forward

Merge and forward multiple messages to the specified recipient.
bash
feishu-cli msg merge-forward \
  --receive-id user@example.com \
  --receive-id-type email \
  --message-ids om_xxx,om_yyy,om_zzz
ParameterDescriptionDefault Value
--receive-id
Recipient IDRequired
--receive-id-type
Recipient type
email
--message-ids
List of message IDs (comma-separated)Required

Reaction Emoji Response

Add/remove/query emoji reactions for messages.
bash
# Add emoji
feishu-cli msg reaction add <message_id> --emoji-type THUMBSUP

# Remove emoji
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]
Common emoji-type values:
THUMBSUP
(Like),
SMILE
(Smile),
LAUGH
(Laugh),
HEART
(Love),
JIAYI
(Plus One),
OK
,
FIRE

Pin Messages

bash
# Pin message
feishu-cli msg pin <message_id>

# Unpin message
feishu-cli msg unpin <message_id>

# Get list of pinned messages in group
feishu-cli msg pins --chat-id <chat_id> [--start-time <ms_timestamp>] [--end-time <ms_timestamp>]
--start-time
and
--end-time
use millisecond-level timestamps.

Other Message Commands

Get Message Details

bash
feishu-cli msg get <message_id>
feishu-cli msg get om_xxx --output json

Forward Message

bash
feishu-cli msg forward <message_id> \
  --receive-id user@example.com \
  --receive-id-type email

Delete Message

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

Get Message List

bash
feishu-cli msg list \
  --container-id oc_xxx \
  --container-id-type chat \
  --page-size 20 \
  --sort-type ByCreateTimeDesc
Supported parameters:
--start-time
,
--end-time
(second-level timestamp),
--page-token
.

Get Conversation History

bash
feishu-cli msg history \
  --container-id oc_xxx \
  --container-id-type chat \
  --sort-type ByCreateTimeAsc \
  --page-size 50

Query Message Read Users

bash
feishu-cli msg read-users <message_id>
feishu-cli msg read-users om_xxx --user-id-type user_id --page-size 50

Search Group Chats

bash
feishu-cli msg search-chats --query "Project Group"
feishu-cli msg search-chats --page-size 20

Search Messages (Requires User Access Token)

bash
feishu-cli search messages "keyword" \
  --user-access-token u-xxx \
  --chat-ids oc_xxx \
  --message-type file \
  --start-time 1704067200

Execution Process

When Claude sends messages, follow these steps:
  1. Determine Recipient: Default is
    user@example.com
    (email), or obtained from context
  2. Select Message Type:
    • If user explicitly specifies type → use the specified type
    • Default to
      interactive
      (card message)
      → select header color and appropriate component layout based on content semantics
    • Use
      text
      /
      post
      only when user explicitly requests plain text/rich text
  3. Construct Card Content:
    • Select header color based on message semantics (Green=Success, Red=Error, Orange=Warning, Blue=Notification, Grey=Archived)
    • Use
      markdown
      component to carry main content
    • Use
      div
      +
      fields
      multi-column layout when there are multiple key-value pairs
    • Add
      action
      +
      button
      when operation links are needed
    • Add
      note
      at the bottom to indicate the source
    • Write the JSON to a temporary file and send it using
      --content-file
  4. Send and Check Result: Execute the command and confirm the returned message_id

Permission Requirements

PermissionDescription
im:message
Message read/write
im:message:send_as_bot
Send messages as bot
im:chat:readonly
Search group chats
im:message:readonly
Get historical messages

Notes

LimitDescription
text size limitMaximum 150 KB per message
card/rich text size limitMaximum 30 KB per message
system messageOnly valid in p2p conversations, invalid in group chats
sticker messageOnly supports forwarding received stickers, does not support uploading custom stickers
card button callbackThe interaction callback of buttons requires application server support; buttons sent via CLI only support url redirection
API rate limitReturns 429 if requests are too frequent, retry after a few seconds
Delete messageOnly messages sent by the bot can be deleted

Error Handling

ErrorCauseSolution
content format of a post type is incorrect
Incorrect JSON format for post typeEnsure the format is
{"zh_cn":{"title":"","content":[[...]]}}
invalid receive_id
Invalid recipient IDCheck if --receive-id-type and --receive-id match
bot has no permission
Bot has no permissionConfirm the application has the
im:message:send_as_bot
permission
rate limit exceeded
API rate limit exceededRetry after a few seconds
user not found
User does not existCheck if the email or ID is correct
card content too large
Card JSON exceeds 30 KBSimplify card content or split into multiple messages

Reference Documents

  • references/message_content.md
    : Detailed explanation of content JSON structure for each message type
  • references/card_schema.md
    : Complete guide to constructing card messages (components, layout, templates)