← 返回 Skills 市场
Feishu Doc
作者
lhq2103387078
· GitHub ↗
· v1.0.0
· MIT-0
55
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install feishu-create-doc
功能描述
飞书云文档创建与管理。当用户提到"创建飞书文档"、"新建飞书文档"、"生成文档发送到飞书"、"飞书文档写入"等时使用。 支持创建带标题和富文本内容的飞书文档,包含段落、标题、列表等格式。
使用说明 (SKILL.md)
飞书文档创建
核心流程
1. 获取用户授权(仅首次)
若 feishu-user-token.json 不存在或 token 过期,需要用户重新授权:
授权链接:
https://open.feishu.cn/open-apis/authen/v1/authorize?client_id=cli_a95aca1714f89cd2&redirect_uri=http://localhost:6010/oauth/feishu/callback&scope=offline_access docx:document docx:document:create docx:document.block:convert&response_type=code
用户访问链接 → 授权 → 飞书跳转回 localhost:6010 → 回调 URL 中的 code=xxx 即为授权码
2. 交换 Token
import urllib.request
# 1. 获取 app_access_token
app_body = '{"app_id":"cli_a95aca1714f89cd2","app_secret":"oq9F8U4J3dnAyYR9AHRnigntKkOKPQ1K"}'
req = urllib.request.Request(
"https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal",
data=app_body.encode("utf-8"),
headers={"Content-Type": "application/json; charset=utf-8"},
method="POST"
)
app_token = json.loads(urllib.request.urlopen(req).read().decode("utf-8"))["app_access_token"]
# 2. 用 code 换取 user_access_token
code = "用户授权后获得的code"
user_body = json.dumps({"grant_type": "authorization_code", "code": code}).encode("utf-8")
req = urllib.request.Request(
"https://open.feishu.cn/open-apis/authen/v1/oidc/access_token",
data=user_body,
headers={
"Authorization": f"Bearer {app_token}",
"Content-Type": "application/json; charset=utf-8"
},
method="POST"
)
result = json.loads(urllib.request.urlopen(req).read().decode("utf-8"))
user_token = result["data"]["access_token"]
refresh_token = result["data"]["refresh_token"]
3. 创建文档(关键:请求体格式!)
import json, urllib.request
token = "user_access_token"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json; charset=utf-8"
}
# 创建文档 - 请求体直接用 {"title": "标题"} 而不是 {"document_style": {"title": ...}}!
body = json.dumps({"title": "文档标题"}, ensure_ascii=False).encode("utf-8")
req = urllib.request.Request(
"https://open.feishu.cn/open-apis/docx/v1/documents",
data=body,
headers=headers,
method="POST"
)
doc_id = json.loads(urllib.request.urlopen(req).read().decode("utf-8"))["data"]["document"]["document_id"]
4. 添加内容块
base_url = f"https://open.feishu.cn/open-apis/docx/v1/documents/{doc_id}/blocks/{doc_id}/children"
def add_text(text, indent=0):
block = {"block_type": 2, "text": {"elements": [{"type": "text_run", "text_run": {"content": text}}]}}
if indent > 0:
block["style"] = {"indent_level": indent}
body = json.dumps({"children": [block]}, ensure_ascii=False).encode("utf-8")
req = urllib.request.Request(base_url, data=body, headers=headers, method="POST")
urllib.request.urlopen(req)
def add_heading(text, level=1):
key = f"heading{level}"
block = {"block_type": level + 2, key: {"elements": [{"type": "text_run", "text_run": {"content": text}}]}}
body = json.dumps({"children": [block]}, ensure_ascii=False).encode("utf-8")
req = urllib.request.Request(base_url, data=body, headers=headers, method="POST")
urllib.request.urlopen(req)
Block Type 参考:
| Type | 类型 |
|---|---|
| 2 | 文本段落 |
| 3 | 一级标题 |
| 4 | 二级标题 |
| 5 | 三级标题 |
关键要点
- 请求体格式:创建文档用
{"title": "xxx"},不是{"document_style": {"title": ...}} - 编码:所有请求必须用 UTF-8 编码,
Content-Type: application/json; charset=utf-8 - Token 存储:
C:\\Users\\廖洪庆\\.openclaw-autoclaw\\credentials\\feishu-user-token.json - 请求限流:每个请求间隔 0.3-0.5 秒,避免 429 错误
能力标签
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install feishu-create-doc - 安装完成后,直接呼叫该 Skill 的名称或使用
/feishu-create-doc触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
feishu-create-doc 1.0.0
- Initial release: Create and manage Feishu (飞书) cloud documents via API.
- Supports creating documents with titles and rich text (paragraphs, headings, lists, etc.).
- Includes detailed flow for user OAuth authorization, token exchange, and token storage.
- Clear description of necessary API request formats, encoding, and request rate limits.
- Reference for content block types and how to add them programmatically.
元数据
常见问题
Feishu Doc 是什么?
飞书云文档创建与管理。当用户提到"创建飞书文档"、"新建飞书文档"、"生成文档发送到飞书"、"飞书文档写入"等时使用。 支持创建带标题和富文本内容的飞书文档,包含段落、标题、列表等格式。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 55 次。
如何安装 Feishu Doc?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install feishu-create-doc」即可一键安装,无需额外配置。
Feishu Doc 是免费的吗?
是的,Feishu Doc 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Feishu Doc 支持哪些平台?
Feishu Doc 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Feishu Doc?
由 lhq2103387078(@lhq2103387078)开发并维护,当前版本 v1.0.0。
推荐 Skills