Feishu Group Chat Guide
Quick Start: Configure renderMode
⚠️ IMPORTANT: Set renderMode explicitly for stable message formatting
CODEBLOCK0
Why? The default "auto" mode causes unpredictable format switching (raw vs card), creating poor user experience.
Configuration:
CODEBLOCK1
Verify:
openclaw config get channels.feishu.renderMode
Prerequisites
- 1. In a Feishu group - OpenClaw connected to Feishu
- Configure renderMode - Set to "card" for consistent formatting
- Know member IDs:
- Human:
open_id (ou_xxx format)
- Bot:
App ID (cli_xxx format)
0. Message Format Stability
The Problem: Raw vs Card Mixing
Without proper renderMode configuration, messages can inconsistently appear as:
- - Raw text: Plain markdown source, no formatting
- Card format: Rendered markdown with syntax highlighting, tables, links
The Solution: Explicit renderMode
| Mode | Behavior | Use Case |
|---|
| INLINECODE3 | Detects content, uses card for code/tables | ❌ Avoid - unpredictable |
| INLINECODE4 |
Always plain text | Simple text-only responses |
|
card | Always interactive card | ✅
Recommended - consistent |
Recommended: renderMode: "card" for all production use.
1. Message Sending
⚠️ CRITICAL: Only Use ONE Method
DO NOT use both direct reply and message tool for the same content! This will send two messages.
Choose ONE:
- - Plain text → message tool only
- Markdown → direct reply only
Two Methods
| Method | Tool | Render Mode | Use Case |
|---|
| message tool | INLINECODE7 | Raw (plain text) | Plain text, @ mentions |
| Direct reply |
Session reply | Card (with Markdown) | Markdown formatted messages |
Raw Mode (Plain Text)
When to use: Plain text messages, @ mentions
How to send:
CODEBLOCK3
@ Mention format:
CODEBLOCK4
Raw Mode Limitations:
- - ❌ No Markdown rendering (bold, italic, code blocks won't render)
- ❌ Tables won't render
- ❌ Links won't render
- ✅ @ mentions work correctly
Card Mode (Markdown)
When to use: Formatted messages with code blocks, tables, bold/italic text
How to send: Direct reply in session with Markdown elements.
Card Mode Triggers (any of these):
- - Code blocks ``
CODEBLOCK5
<at id=ou_xxx></at> This is Card mode @ mention
**Markdown content** renders correctly
CODEBLOCK6 code ` | ✅ Supported |
| Tables | | table | | ✅ Supported |
**Not Supported in Card Mode**:
| Style | Syntax | Status |
|-------|--------|--------|
| Blockquote | > quote | ❌ Not supported |
| Inline code | code | ❌ Unstable |
| Horizontal rule | --- | ❌ Not supported |
| Complex nesting | Multiple levels | ❌ Unstable |
**Best Practice for Card Mode**:
- Use bold for emphasis
- Use italic for light emphasis
- Use numbered lists 1. or bullet lists -
- Avoid ---, >, and inline code
- Keep formatting simple
### Avoid Auto Mode
**Problem**: Auto mode can incorrectly choose between Raw and Card.
**Best Practice**:
- **Plain text** → Use message tool (Raw mode)
- **Markdown content** → Direct reply (Card mode)
**Don't**:
- Use message tool for Markdown (won't render)
- Use complex structures in Card mode (may trigger Raw incorrectly)
---
## 2. Group Member Management
### ⚠️ Important: Bots Only See @ Mentioned Messages
**Bots can only see messages that @ mention them!** If a group member sends a message without @ mentioning the bot, the bot won't receive it.
This means:
- To identify a human member's open_id, they must **@ mention the bot and send a message**
- The bot cannot see past messages where it wasn't mentioned
### How to Get Member IDs
**Human open_id** (must @ mention bot):
1. Ask the human to @ mention the bot and send any message
2. When the message arrives, the system shows:
[Feishu ocxxx:ouxxx timestamp] nickname: message content
3. The ouxxx is the sender's open_id
**Bot App ID** (requires user to provide):
1. Go to Feishu Developer Console: https://open.feishu.cn/app
2. Click on the bot you want to view
3. In "Application Credentials" (应用凭证), copy the App ID (cli_xxx format)
4. @ mention the bot and send the App ID
### Maintain Member List
Store member info in memory file:
CODEBLOCK7
---
## 3. @ Mention Tips
### @ Format Difference (Critical!)
| Mode | @ Format | Example |
|------|----------|---------|
| Raw (message tool) | id="ID">nickname | id="ouxxx">kk |
| Card (direct reply) | | xxx> |
### @ Different Target Types
| @ Target | ID Type | Raw Format | Card Format |
|----------|---------|------------|-------------|
| Human | open_id (ou_xxx) | id="ouxxx">nickname | xxx> |
| Bot | App ID (cli_xxx) | id="clixxx">botname | xxx> |
| Everyone | "all" | id="all">everyone | |
### @ Bot vs @ Human
**Important difference**:
- **Bots**: **MUST be @ mentioned to receive messages!** Without @, bots won't get notified
- **Humans**: Can see all group messages, @ not required
**⚠️ Feishu Limitation: Bot-to-Bot Messages**
- A bot CAN send messages and @ mention another bot
- But **bots can only receive messages from human accounts**
- Bots **cannot receive messages from other bots**
- Therefore, **@ mentioning another bot will NOT notify that bot**
**Practical implication**:
- If you need to communicate with another bot, ask a human to send the message instead
- Bot-to-bot communication is not possible in Feishu groups
**Example - @ Bot**:
CODEBLOCK8
CODEBLOCK9
### @ Everyone
**Note**: Requires group permission (Group Settings > Group Management > Who can @everyone)
CODEBLOCK10
CODEBLOCK11
### Common @ Mistakes
**Raw mode errors**:
- @nickname - Plain text, no notification
- @{nickname} - Plain text
- - id attribute doesn't work in Raw mode
**Card mode errors**:
- id="ou_xxx">nickname - user_id attribute doesn't work in Card mode
---
## 4. Quick Reference
### Message Decision Tree
CODEBLOCK12
### @ Mention Decision Tree
CODEBLOCK13
### ID Format Reference
| Type | Format | Example |
|------|--------|---------|
| Human open_id | ou_xxx | ou_example123abc |
| Bot App ID | cli_xxx | cli_example456def |
| Group chat_id | oc_xxx | oc_example789ghi |
---
## 5. Important Notes
1. **Card and Raw mode use different @ formats** - Wrong format = @ fails
2. **Bots MUST be @ mentioned to receive messages** - Humans don't need @
3. **Bot-to-bot communication is NOT possible** - Bots can only receive messages from humans, not other bots
4. **message tool only sends Raw mode** - No Markdown rendering
5. **@everyone requires group permission**
6. **Avoid unsupported styles in Card mode** (blockquote, inline code, horizontal rule)
---
## 6. Configuration Reference
### renderMode Settings
**Location:** OpenClaw config file or environment
**Quick Setup:**
CODEBLOCK14
**Environment-specific configurations:**
**Development:**
CODEBLOCK15
**Production:**
CODEBLOCK16
### Troubleshooting
**Messages appear as raw markdown:**
1. Check: openclaw config get channels.feishu.renderMode
2. Set: openclaw config set channels.feishu.renderMode "card"
3. Restart: openclaw gateway restart
**Format switches between raw and card:**
- Cause: Using renderMode: "auto"
- Fix: Change to "card" or "raw" explicitly
**Proactive messages not using card:**
- Expected: Proactive messages (via message tool) always use plain text
- Workaround: Have user send a message first, then reply
---
## Source
- Tested on: OpenClaw Feishu integration
- Test date: 2026-02-27 ~ 2026-02-28
- Source files:
- /home/admin/.openclaw/extensions/feishu/src/bot.ts
- /home/admin/.openclaw/extensions/feishu/src/reply-dispatcher.ts
- /home/admin/.openclaw/extensions/feishu/src/mention.ts
- /home/admin/.openclaw/extensions/feishu/src/send.ts`
飞书群聊指南
快速开始:配置renderMode
⚠️ 重要提示:显式设置renderMode以确保消息格式稳定
yaml
推荐配置
channels:
feishu:
renderMode: card # 始终使用卡片格式
原因? 默认的auto模式会导致不可预测的格式切换(原始文本 vs 卡片),造成糟糕的用户体验。
配置方法:
bash
openclaw config set channels.feishu.renderMode card
openclaw gateway restart
验证方法:
bash
openclaw config get channels.feishu.renderMode
前置条件
- 1. 在飞书群中 - OpenClaw已连接到飞书
- 配置renderMode - 设置为card以确保格式一致
- 了解成员ID:
- 人类:open
id(ouxxx格式)
- 机器人:App ID(cli_xxx格式)
0. 消息格式稳定性
问题:原始文本与卡片混合
如果没有正确配置renderMode,消息可能会不一致地显示为:
- - 原始文本:纯Markdown源码,无格式
- 卡片格式:渲染后的Markdown,包含语法高亮、表格、链接
解决方案:显式设置renderMode
| 模式 | 行为 | 使用场景 |
|---|
| auto | 检测内容,代码/表格使用卡片 | ❌ 避免使用 - 不可预测 |
| raw |
始终使用纯文本 | 仅纯文本响应 |
| card | 始终使用交互式卡片 | ✅
推荐使用 - 一致性 |
推荐: 所有生产环境使用renderMode: card。
1. 消息发送
⚠️ 关键提示:仅使用一种方法
不要对同一内容同时使用直接回复和消息工具! 这将发送两条消息。
选择一种:
- - 纯文本 → 仅使用消息工具
- Markdown → 仅使用直接回复
两种方法
| 方法 | 工具 | 渲染模式 | 使用场景 |
|---|
| 消息工具 | message | 原始(纯文本) | 纯文本、@提及 |
| 直接回复 |
会话回复 | 卡片(含Markdown) | Markdown格式消息 |
原始模式(纯文本)
使用时机:纯文本消息、@提及
发送方法:
javascript
message({
action: send,
channel: feishu,
target: oc_xxx,
message: 纯文本内容
})
@提及格式:
javascript
message({
action: send,
channel: feishu,
target: oc_xxx,
message: id=\ouxxx\>昵称 你好!
})
原始模式限制:
- - ❌ 不支持Markdown渲染(粗体、斜体、代码块不会渲染)
- ❌ 表格不会渲染
- ❌ 链接不会渲染
- ✅ @提及正常工作
卡片模式(Markdown)
使用时机:包含代码块、表格、粗体/斜体文本的格式化消息
发送方法:在会话中直接回复包含Markdown元素的内容。
卡片模式触发条件(满足任一即可):
- - 代码块
- 表格 | 表格 |
- 粗体 粗体
- 斜体 斜体
- 删除线 ~~文本~~
- 链接 链接
- 标题 # 标题
- 列表 - 项目 或 1. 项目
@提及格式:
这是卡片模式的@提及
Markdown内容 正确渲染
卡片模式支持的内容:
斜体 | ✅ 支持 |
| 删除线 | ~~文本~~ | ✅ 支持 |
| 颜色 |
文本 | ✅ 支持 |
| 链接 |
链接 | ✅ 支持 |
| 标题 | # 标题 | ✅ 支持 |
| 列表 | - 项目 或 1. 项目 | ✅ 支持 |
| 代码块 | 代码 | ✅ 支持 |
| 表格 | | 表格 | | ✅ 支持 |
卡片模式不支持的内容:
代码 | ❌ 不稳定 |
| 水平线 | --- | ❌ 不支持 |
| 复杂嵌套 | 多层结构 | ❌ 不稳定 |
卡片模式最佳实践:
- - 使用粗体强调
- 使用斜体轻度强调
- 使用数字列表1.或无序列表-
- 避免使用---、>和行内代码
- 保持格式简洁
避免自动模式
问题:自动模式可能错误地在原始模式和卡片模式之间选择。
最佳实践:
- - 纯文本 → 使用消息工具(原始模式)
- Markdown内容 → 直接回复(卡片模式)
不要:
- - 使用消息工具发送Markdown(不会渲染)
- 在卡片模式中使用复杂结构(可能错误触发原始模式)
2. 群成员管理
⚠️ 重要提示:机器人只能看到@提及的消息
机器人只能看到@提及它们的消息! 如果群成员发送的消息没有@提及机器人,机器人将无法收到。
这意味着:
- - 要获取人类成员的open_id,他们必须@提及机器人并发送消息
- 机器人无法看到未提及它的历史消息
如何获取成员ID
人类open_id(必须@提及机器人):
- 1. 请人类@提及机器人并发送任意消息
- 消息到达时,系统显示:
[Feishu oc
xxx:ouxxx 时间戳] 昵称: 消息内容
- 3. ouxxx就是发送者的openid
机器人App ID(需要用户提供):
- 1. 前往飞书开发者控制台:https://open.feishu.cn/app
- 点击要查看的机器人
- 在应用凭证中,复制App ID(cli_xxx格式)
- @提及机器人并发送App ID
维护成员列表
将成员信息存储在记忆文件中:
markdown
群成员(oc_xxx)
人类
AI机器人
- - 机器人1:cli_xxx(必须@才能接收消息)
3. @提及技巧
@格式差异(关键!)
| 模式 | @格式 | 示例 |
|---|
| 原始(消息工具) | <at userid=ID>昵称</at> | <at userid=ouxxx>kk</at> |
| 卡片(直接回复) |
|
xxx> |
@不同目标类型
| @目标 | ID类型 | 原始格式 | 卡片格式 |
|---|
| 人类 | openid(ouxxx) | <at userid=ouxxx>昵称</at> | <at id=ouxxx></at> |
| 机器人 |
App ID(clixxx) |
id=clixxx>机器人名 |
|
| 所有人 | all |
所有人 |
|
@机器人与@人类的区别
重要区别:
- - 机器人:必须被@提及才能接收消息! 没有@,机器人不会收到通知
- 人类:可以看到所有群消息,不需要@
⚠️ 飞书限制:机器人之间的消息
- - 机器人可以发送消息并@提及另一个机器人
- 但机器人只能接收来自人类账号的消息
- 机器人无法接收来自其他机器人的消息
- 因此,@提及另一个机器人不会通知该机器人
实际影响:
- - 如果需要与另一个机器人通信,请让人类发送消息
- 飞书群中无法实现机器人之间的通信
示例 - @机器人:
javascript
// 原始模式
message({
action: send,
channel: