Back to Skills

企业协同办公编排

用开放平台接口处理飞书文档、表格、日程和待办。 适合从有权限的文档提取摘要、整理项目跟进信息,或在明确确认后回填到飞书。 SkillHub 第三方中文版本,原作来自 Ace Data Cloud。需配置飞书 OAuth 权限。发送消息及写入操作应由用户确认。

Version: 1.0.0Contributor: org-b6kzcl68Category: 办公效率
团队协作在线表格文档飞书

Use “企业协同办公编排” in Tokeny

  1. Download the Tokeny app
  2. Install this skill in one click
  3. Use it directly in chat
Already installed? Open in Tokeny

SKILL.md

我们使用 curl + jq 驱动开放平台接口。用户的 OAuth user_access_token 位于 $FEISHU_TOKEN;每次调用都把它作为 Authorization: Bearer $FEISHU_TOKEN 发送。所有端点都位于 https://open.feishu.cn/open-apis 下。

调用在用户的上下文中运行(他们的文档、日历、消息)—— 只能访问用户有权访问的数据,且仅限于连接时授予的权限范围(文档 / 表格 / 多维表格 / 云盘 / 日历 / 即时消息 / 知识库 / 任务 / 通讯录)。

响应结构与错误处理

每个响应都是 {"code": 0, "msg": "success", "data": {…}}。code == 0 表示成功;任何非零 code 都是错误 —— 请把 msg 展示给用户。务必检查:

resp=$(curl -sS … )
echo "$resp" | jq 'if .code == 0 then .data else error("Feishu \(.code): \(.msg)") end'

常见错误码:

错误码含义处理方式
99991663 / 99991668访问令牌无效 / 已过期告知用户在连接设置中重新连接该平台
99991661无权限(未授予相应权限范围)连接时缺少该权限 —— 重新连接并授予
1254xxx资源不存在 / 无访问权限用户看不到那份文档 / 表格 / 应用 —— 仔细核对令牌 / ID

用法示例

验证认证(务必最先运行)

curl -sS https://open.feishu.cn/open-apis/authen/v1/user_info \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then {name: .data.name, open_id: .data.open_id, email: .data.email} else . end'

文档

文档链接形如 https://…feishu.cn/docx/<document_id>。其中 document_id 是路径的最后一段。

读取文档的纯文本:

curl -sS "https://open.feishu.cn/open-apis/docx/v1/documents/DOCUMENT_ID/raw_content" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq -r 'if .code == 0 then .data.content else "ERR \(.code): \(.msg)" end'

列出文档的块(结构化内容):

curl -sS "https://open.feishu.cn/open-apis/docx/v1/documents/DOCUMENT_ID/blocks?page_size=500" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.items[] | {block_id, block_type}] else . end'

新建空白文档(可选放入某个文件夹):

curl -sS -X POST "https://open.feishu.cn/open-apis/docx/v1/documents" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc --arg title "会议纪要 2026-07-01" '{title: $title}')" \
  | jq 'if .code == 0 then {document_id: .data.document.document_id} else . end'

向文档追加文本块(插入到文档正文末尾 —— DOCUMENT_ID 同时也是根块 ID):

curl -sS -X POST "https://open.feishu.cn/open-apis/docx/v1/documents/DOCUMENT_ID/blocks/DOCUMENT_ID/children" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc --arg text "由助手追加的一段内容。" '
    {children: [{block_type: 2, text: {elements: [{text_run: {content: $text}}]}}]}')" \
  | jq 'if .code == 0 then "appended" else . end'

电子表格

表格链接形如 https://…feishu.cn/sheets/<spreadsheet_token>。区域格式为 <sheetId>!<A1:range>,例如 abc123!A1:D10。如果没有工作表 ID,请先通过元信息接口列出工作表 ID。

读取区域:

curl -sS "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/SPREADSHEET_TOKEN/values/RANGE" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then .data.valueRange.values else . end'

在最后一个非空行之后追加行:

curl -sS -X POST "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/SPREADSHEET_TOKEN/values_append" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc '{valueRange: {range: "SHEET_ID!A1:B1", values: [["张三", 100], ["李四", 200]]}}')" \
  | jq 'if .code == 0 then .data.updates else . end'

多维表格

多维表格链接形如 https://…feishu.cn/base/<app_token>。通过 …/bitable/v1/apps/APP_TOKEN/tables 获取 table_id。

列出记录:

curl -sS "https://open.feishu.cn/open-apis/bitable/v1/apps/APP_TOKEN/tables/TABLE_ID/records?page_size=100" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.items[] | {record_id, fields}] else . end'

创建记录:

curl -sS -X POST "https://open.feishu.cn/open-apis/bitable/v1/apps/APP_TOKEN/tables/TABLE_ID/records" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc '{fields: {"标题": "新任务", "状态": "待办"}}')" \
  | jq 'if .code == 0 then {record_id: .data.record.record_id} else . end'

云盘文件

列出文件夹中的文件(省略 folder_token 表示根目录):

curl -sS "https://open.feishu.cn/open-apis/drive/v1/files?folder_token=FOLDER_TOKEN&page_size=50" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.files[] | {name, type, token, url}] else . end'

日历

列出用户的日历(主日历带有 type: "primary"):

curl -sS "https://open.feishu.cn/open-apis/calendar/v4/calendars?page_size=50" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.calendar_list[] | {calendar_id, summary, type}] else . end'

列出时间窗口内的日程(时间戳秒数字符串):

curl -sS "https://open.feishu.cn/open-apis/calendar/v4/calendars/CALENDAR_ID/events?start_time=1751299200&end_time=1751385600&page_size=100" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.items[] | {summary, start: .start_time, end: .end_time, event_id}] else . end'

创建日程(时间为时间戳秒数字符串):

curl -sS -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars/CALENDAR_ID/events" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc '{summary: "项目评审", start_time: {timestamp: "1751302800"}, end_time: {timestamp: "1751306400"}}')" \
  | jq 'if .code == 0 then {event_id: .data.event.event_id} else . end'

任务

列出用户的任务:

curl -sS "https://open.feishu.cn/open-apis/task/v2/tasks?page_size=50" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.items[] | {summary, completed_at, task_guid: .guid}] else . end'

创建任务:

curl -sS -X POST "https://open.feishu.cn/open-apis/task/v2/tasks" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc '{summary: "准备周会材料"}')" \
  | jq 'if .code == 0 then {task_guid: .data.task.guid} else . end'

知识库

先列出知识库空间,再列出空间中的节点:

curl -sS "https://open.feishu.cn/open-apis/wiki/v2/spaces?page_size=50" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.items[] | {space_id, name}] else . end'

curl -sS "https://open.feishu.cn/open-apis/wiki/v2/spaces/SPACE_ID/nodes?page_size=50" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  | jq 'if .code == 0 then [.data.items[] | {title, node_token, obj_type}] else . end'

发送即时消息

按 open_id 发送给用户(群聊使用 receive_id_type=chat_id)。content 必须是 JSON 字符串,因此需要双重编码:

curl -sS -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
  -H "Authorization: Bearer $FEISHU_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -nc --arg rid "ou_xxx" --arg text "你好,这是助手发送的消息。" '
    {receive_id: $rid, msg_type: "text", content: ({text: $text} | tostring)}')" \
  | jq 'if .code == 0 then {message_id: .data.message_id} else . end'

注意事项

  • 破坏性或对外可见的操作(发送消息、创建日程邀请、在共享文档中发帖)运行前请先与用户确认。
  • 分页:列表接口返回 data.page_token / data.has_more;传入 page_token=… 可获取下一页。
  • 当用户粘贴平台链接时,请从 URL 路径中提取令牌/ID,而不要再去询问用户。

What is Tokeny?

  • A free desktop AI assistant for Windows, macOS and Linux.
  • Describe a task to process files, create documents and spreadsheets, or run multi-step work.
  • Extend it with skills and MCP servers installed from the marketplace in one click.
Learn about Tokeny

评论与讨论

0/2000

还没有评论,分享你的体验吧。