让AI Agent接管你的飞书工作区 — 消息、文档、表格、日历全自动化
# openclaw.yaml 中的飞书配置
channels:
feishu:
enabled: true
appId: "cli_xxxxxxxxxx"
appSecret: "xxxxxxxxxxxxxxxx"
encryptKey: "xxxxxxxxxxxxxxxx"
verificationToken: "xxxxxxxxxxxxxxxx"
# 或者通过环境变量
export FEISHU_APP_ID="cli_xxxxxxxxxx"
export FEISHU_APP_SECRET="xxxxxxxxxxxxxxxx"
| 权限 | scope | 用途 |
|---|---|---|
| 消息收发 | im:message | 发送和接收消息 |
| 群管理 | im:chat | 创建和管理群聊 |
| 云文档 | docx:document | 读写云文档 |
| 多维表格 | bitable:app | 操作多维表格 |
| 日历 | calendar:calendar | 管理日程 |
| 任务 | task:task | 创建和管理任务 |
| 知识库 | wiki:wiki | 管理知识库 |
// 发送文本消息到群聊
message({
action: "send",
channel: "feishu",
target: "oc_c942dfd09730eb94bf838c6519c115e9",
message: "今天的AI日报已生成,请查看:https://miaoquai.com/news/"
})
// 发送富文本消息
feishu_im_user_message({
action: "send",
receive_id_type: "chat_id",
receive_id: "oc_c942dfd09730eb94bf838c6519c115e9",
msg_type: "post",
content: JSON.stringify({
zh_cn: {
title: "📊 今日数据报告",
content: [[
{ tag: "text", text: "网站访问量:" },
{ tag: "text", text: "12,345", style: ["bold"] },
{ tag: "text", text: "\n较昨日增长 " },
{ tag: "text", text: "+15%", style: ["bold"] }
]]
}
})
})
// 获取群聊历史消息
feishu_im_user_get_messages({
chat_id: "oc_c942dfd09730eb94bf838c6519c115e9",
page_size: 20,
sort_rule: "create_time_desc"
})
// 搜索消息
feishu_im_user_search_messages({
query: "SEO报告",
chat_id: "oc_c942dfd09730eb94bf838c6519c115e9",
relative_time: "last_7_days"
})
// 发送交互式消息卡片
feishu_im_user_message({
action: "send",
receive_id_type: "chat_id",
receive_id: "oc_xxx",
msg_type: "interactive",
content: JSON.stringify({
header: {
title: { tag: "plain_text", content: "🚀 任务状态更新" },
template: "blue"
},
elements: [
{
tag: "div",
text: { tag: "lark_md", content: "**任务名称**: SEO日报生成\n**状态**: ✅ 已完成\n**耗时**: 2分35秒" }
},
{
tag: "action",
actions: [
{
tag: "button",
text: { tag: "plain_text", content: "查看报告" },
url: "https://miaoquai.com/news/",
type: "primary"
}
]
}
]
})
})
// 从Markdown创建飞书文档
feishu_create_doc({
title: "2026年6月AI行业报告",
markdown: `# 2026年6月AI行业报告
## 概述
本月AI行业呈现以下趋势...
## 关键数据
- OpenClaw用户增长: +45%
- ClawHub Skills数量: 3,286+
- AI Agent市场规模: $12.4B
## 详细分析
...
`,
folder_token: "fldcnxxxxxxxx"
})
// 获取文档内容
feishu_fetch_doc({
doc_id: "doxcnxxxxxxxx"
})
// 搜索文档
feishu_search_doc_wiki({
action: "search",
query: "AI Agent",
filter: {
doc_types: ["DOCX"],
sort_type: "EDIT_TIME"
}
})
// 追加内容到文档末尾
feishu_update_doc({
doc_id: "doxcnxxxxxxxx",
mode: "append",
markdown: "\n## 新增章节\n\n这是追加的内容..."
})
// 替换指定章节
feishu_update_doc({
doc_id: "doxcnxxxxxxxx",
mode: "replace_range",
selection_by_title: "## 关键数据",
markdown: "## 关键数据(已更新)\n\n- 新数据1\n- 新数据2"
})
// 创建多维表格
feishu_bitable_app({
action: "create",
name: "SEO监控数据表"
})
// 创建数据表
feishu_bitable_app_table({
action: "create",
app_token: "bascnxxxxxxxx",
table: {
name: "关键词排名",
fields: [
{ field_name: "关键词", type: 1 }, // 文本
{ field_name: "排名", type: 2 }, // 数字
{ field_name: "搜索量", type: 2 }, // 数字
{ field_name: "状态", type: 3, property: { // 单选
options: [
{ name: "上升", color: 0 },
{ name: "下降", color: 1 },
{ name: "稳定", color: 2 }
]
}},
{ field_name: "更新日期", type: 5 } // 日期
]
}
})
// 添加记录
feishu_bitable_app_table_record({
action: "create",
app_token: "bascnxxxxxxxx",
table_id: "tblxxxxxxxx",
fields: {
"关键词": "OpenClaw教程",
"排名": 3,
"搜索量": 12500,
"状态": "上升",
"更新日期": Date.now()
}
})
// 批量添加
feishu_bitable_app_table_record({
action: "batch_create",
app_token: "bascnxxxxxxxx",
table_id: "tblxxxxxxxx",
records: [
{ fields: { "关键词": "AI Agent", "排名": 1, "搜索量": 45000 } },
{ fields: { "关键词": "ClawHub", "排名": 5, "搜索量": 8200 } }
]
})
// 查询记录
feishu_bitable_app_table_record({
action: "list",
app_token: "bascnxxxxxxxx",
table_id: "tblxxxxxxxx",
filter: {
conjunction: "and",
conditions: [
{ field_name: "状态", operator: "is", value: ["上升"] }
]
},
sort: [{ field_name: "排名", desc: false }]
})
// 创建日程
feishu_calendar_event({
action: "create",
summary: "SEO策略会议",
description: "讨论本月SEO优化方向和内容计划",
start_time: "2026-06-10T14:00:00+08:00",
end_time: "2026-06-10T15:00:00+08:00",
attendees: [
{ type: "user", id: "ou_xxxxxxxxxx" }
],
reminders: [{ minutes: 15 }]
})
// 查询日程
feishu_calendar_event({
action: "list",
start_time: "2026-06-08T00:00:00+08:00",
end_time: "2026-06-14T23:59:59+08:00"
})
// 查询忙闲
feishu_calendar_freebusy({
action: "list",
time_min: "2026-06-10T09:00:00+08:00",
time_max: "2026-06-10T18:00:00+08:00",
user_ids: ["ou_xxxxxxxxxx"]
})
// 创建任务
feishu_task_task({
action: "create",
summary: "完成6月SEO月报",
description: "汇总本月SEO数据,包括关键词排名、流量变化、收录情况",
due: { timestamp: "2026-06-30T18:00:00+08:00" },
members: [
{ id: "ou_xxxxxxxxxx", type: "user", role: "assignee" }
]
})
// 创建子任务
feishu_task_subtask({
action: "create",
task_guid: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
summary: "收集关键词排名数据",
due: { timestamp: "2026-06-25T18:00:00+08:00" }
})
// 创建任务清单
feishu_task_tasklist({
action: "create",
name: "6月SEO工作清单"
})
// 列出知识空间
feishu_wiki_space({
action: "list"
})
// 列出知识库节点
feishu_wiki_space_node({
action: "list",
space_id: "xxxxxxxxxxxxxxxx"
})
// 在知识库中创建文档
feishu_create_doc({
title: "OpenClaw使用手册",
markdown: "# OpenClaw使用手册\n\n...",
wiki_space: "xxxxxxxxxxxxxxxx"
})
// 完整的日报自动化流程
// 1. 从多维表格获取数据
const records = feishu_bitable_app_table_record({
action: "list",
app_token: "bascnxxxxxxxx",
table_id: "tblxxxxxxxx",
filter: {
conjunction: "and",
conditions: [
{ field_name: "日期", operator: "is", value: ["today"] }
]
}
})
// 2. 生成报告文档
const doc = feishu_create_doc({
title: `${today} SEO日报`,
markdown: generateReport(records)
})
// 3. 发送到群聊
feishu_im_user_message({
action: "send",
receive_id_type: "chat_id",
receive_id: "oc_xxx",
msg_type: "interactive",
content: generateCard(doc)
})
// 4. 创建待办跟进
feishu_task_task({
action: "create",
summary: `跟进${today}日报中的问题`,
due: { timestamp: tomorrow }
})