返回顶部
f

feishu-send-file飞书发送文件

飞书发送本地图片和文件技能。支持向飞书私聊(ou_)和群聊(oc_)发送图片(JPEG/PNG/WEBP 等)及文件(PDF/HTML/ZIP 等)。采用官方推荐的两步法(上传获取 key -> 发送消息),确保内容在飞书客户端正常显示并获得最佳体验。

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
105
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

feishu-send-file

飞书发图片 & 文件 Skill

强制规则(Feishu channel)

  • - 任务产出了图片,必须主动发送到当前会话,不等用户催促。
  • 用户说发给我/群里看图时,必须走脚本,不能只返回本地路径。
  • 发送后记录 code、msg、message_id 用于排查。

关键:receive_id 前缀判断

前缀receiveidtype场景
ou...openid私聊(单人)
oc...
chatid | 群聊 |

脚本已自动判断,不需要手动传 type。

获取凭据

从 OpenClaw 配置读取 appid / appsecret:

bash
grep -A 2 feishu /root/.openclaw/openclaw.json | grep -E (appId|appSecret)

从 context inboundmeta 获取 receiveid(去掉 user: 前缀保留 ou_... 部分)。

发送图片

方式一:用脚本(推荐)

bash
python3 skills/feishu-send-file/scripts/sendimage.py path> id> id> [domain]

参数说明:

  • - imagepath:要发送的图片路径(JPEG/PNG/WEBP/GIF/TIFF/BMP/ICO)
  • receiveid:接收者 ID,支持 ou...(私聊)或 oc...(群聊),脚本自动判断类型
  • appid:飞书应用 ID(从 openclaw.json 的 channels.feishu.appId 读取)
  • appsecret:飞书应用密钥(从 openclaw.json 的 channels.feishu.appSecret 读取)
  • domain:可选,默认 feishu;国际版 Lark 传 lark

示例:

bash

发个人(ou_...)


python3 skills/feishu-send-file/scripts/sendimage.py ./chart.png ouxxx $APPID $APPSECRET

发群(oc_...)

python3 skills/feishu-send-file/scripts/sendimage.py ./chart.png ocxxx $APPID $APPSECRET

国际版 Lark

python3 skills/feishu-send-file/scripts/sendimage.py ./chart.png ouxxx $APPID $APPSECRET lark

完整路径示例:

bash
python3 /root/.openclaw/workspace/skills/feishu-send-file/scripts/send_image.py \
/root/myfiles/generated-images/demo.png \
RECEIVE
ID> \
APPID> \
APPSECRET>

发送文件

方式一:用脚本(推荐)

bash
python3 skills/feishu-send-file/scripts/sendfile.py path> id> id> secret> [filename]

参数说明:

  • - filepath:要发送的文件路径(HTML/PDF/ZIP/代码文件等)
  • receiveid:接收者 ID,支持 ou...(私聊)或 oc...(群聊),脚本自动判断类型
  • appid:飞书应用 ID(从 openclaw.json 的 channels.feishu.appId 读取)
  • appsecret:飞书应用密钥(从 openclaw.json 的 channels.feishu.appSecret 读取)
  • file_name:可选,自定义文件名(不填则用原文件名)

示例:

bash

发个人


python3 skills/feishu-send-file/scripts/sendfile.py ./report.pdf ouxxx $APPID $APPSECRET

发群

python3 skills/feishu-send-file/scripts/sendfile.py ./report.pdf ocxxx $APPID $APPSECRET

完整路径示例:

bash
python3 /root/.openclaw/workspace/skills/feishu-send-file/scripts/send_file.py \
/root/myfiles/report.html \
RECEIVEID> \
APPID> \
APPSECRET> \
report.html

方式二:手动两步

Step 1 - 上传文件:
bash
TOKEN=$(curl -s -X POST https://open.feishu.cn/open-apis/auth/v3/tenantaccesstoken/internal \
-H Content-Type: application/json \
-d {appid:ID>,appsecret:SECRET>} | python3 -c import json,sys; print(json.load(sys.stdin)[tenantaccesstoken]))

FILE_KEY=$(curl -s -X POST https://open.feishu.cn/open-apis/im/v1/files \
-H Authorization: Bearer $TOKEN \
-F file_type=stream \
-F file_name=<文件名> \
-F file=@<文件路径> | python3 -c import json,sys; print(json.load(sys.stdin)[data][file_key]))

Step 2 - 发送消息:
bash
curl -s -X POST https://open.feishu.cn/open-apis/im/v1/messages?receiveidtype=open_id \
-H Authorization: Bearer $TOKEN \
-H Content-Type: application/json \
-d {\receiveid\:\ID>\,\msgtype\:\file\,\content\:\{\\\filekey\\\:\\\$FILE_KEY\\\}\}

脚本底层逻辑说明

发送原理

飞书消息链路中,发送文件或图片的最佳方式是采用两步法:

  1. 1. 先上传:将本地文件上传到 im/v1/files 或 im/v1/images,获取持久化的 filekey 或 imagekey。
  2. 后发送:调用 im/v1/messages 接口,指定 msg_type 为 file 或 image 并携带对应的 Key。

直接传递本地路径字符串到消息接口通常会导致客户端只显示路径文本。本脚本通过自动化这两步流程,确保用户在飞书里实际看到图片本体或可预览的文件。

普通文件 vs 图片的链路区别

  • - 普通文件:im/v1/files -> filekey -> msgtype=file
  • 图片:im/v1/images -> imagekey -> msgtype=image

脚本会自动处理这些差异。

排查

  • - 发送失败先看 code / msg
  • 群发失败检查:机器人已入群 + sendmessage 权限 + 使用正确的 oc chatid
  • oc... 误当 openid 发必定报错
  • 不要把本地路径回显误判为发送成功
  • 飞书 filetype 用 stream 适用于所有普通文件类型

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 feishu-chatfile-skill-1775943270 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 feishu-chatfile-skill-1775943270 技能

通过命令行安装

skillhub install feishu-chatfile-skill-1775943270

下载

⬇ 下载 feishu-send-file v1.0.0(免费)

文件大小: 6.49 KB | 发布时间: 2026-4-12 09:56

v1.0.0 最新 2026-4-12 09:56
Initial release of feishu-send-file skill — send images and files to Feishu chats with the recommended two-step API process.

- Enables sending local images (JPEG, PNG, WEBP, etc.) and files (PDF, HTML, ZIP, etc.) to both private chats (ou_) and group chats (oc_) in Feishu.
- Uses the official two-step method (upload to get key → send message) to ensure correct display in the client.
- Automatically determines receive_id_type based on the receive_id prefix; no need to specify type manually.
- Credentials (app_id, app_secret) are sourced from OpenClaw configuration.
- Provides both script-based (recommended) and manual command-line instructions for sending images/files.
- Includes troubleshooting tips and best practices for reliable file/image delivery.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large