Auto File Sender
Overview
This skill enables automatic file delivery from the workspace to Feishu/Lark users. When files are generated (documents, PDFs, images, etc.), they can be automatically sent to specified recipients without manual intervention.
Key Capabilities:
- - Auto-detect new files in workspace
- Send via Feishu message with file attachment
- Support batch sending of multiple files
- Configurable file type filters and recipient rules
Quick Start
Basic Usage
When a file is ready to send:
CODEBLOCK0
Auto-Send on File Creation
The skill provides a helper script to watch for new files and auto-send:
CODEBLOCK1
Workflow
Step 1: Identify Files to Send
Check for recently created/modified files:
CODEBLOCK2
Step 2: Send Files
Use the message tool with filePath parameter:
CODEBLOCK3
Parameters:
- -
filePath: Absolute path to the file (required) - INLINECODE1 : Display name for the file (optional, defaults to basename)
- INLINECODE2 : Accompanying text message (optional)
- INLINECODE3 : Recipient open_id (defaults to current user if omitted)
Step 3: Confirm Delivery
Check the response for successful delivery:
- -
messageId: ID of the sent message - INLINECODE5 : ID of the chat/channel
Supported File Types
| Type | Extensions | Max Size |
|---|
| Documents | .docx, .doc, .pdf | 30MB |
| Images |
.jpg, .png, .gif, .webp | 30MB |
| Spreadsheets | .xlsx, .xls, .csv | 30MB |
| Archives | .zip, .tar.gz | 30MB |
| Others | Any | 30MB |
Batch Sending
To send multiple files at once:
CODEBLOCK4
Configuration
Default Settings
- - Source directory: INLINECODE6
- Max file size: 30MB (Feishu limit)
- Auto-recipient: Current conversation user
Custom Recipient
To send to a specific user:
CODEBLOCK5
Scripts
scripts/auto_send.py
Python script for watching directories and auto-sending files.
Usage:
CODEBLOCK6
Examples:
CODEBLOCK7
Troubleshooting
File Not Found
- - Ensure file path is absolute
- Verify file exists: INLINECODE7
- Check file permissions
Send Failed
- - Verify file size < 30MB
- Check recipient open_id is correct
- Ensure bot has permission to send files
Large Files
For files > 30MB:
- 1. Compress: INLINECODE8
- Split: INLINECODE9
- Use cloud storage and send link instead
Best Practices
- 1. Always verify files exist before sending
- Use descriptive filenames for better organization
- Batch similar files to reduce API calls
- Clean up sent files periodically to save space
- Log sent files for tracking (optional)
Examples
Example 1: Send Generated Document
User: "Generate a report and send it to me"
CODEBLOCK8
Example 2: Send Multiple Files
User: "Send all the PDFs in my workspace"
CODEBLOCK9
Then send each file using the message tool.
Example 3: Auto-Send on Completion
After a long-running task generates output:
CODEBLOCK10
自动文件发送器
概述
此技能支持将工作区中的文件自动发送给飞书用户。当文件(文档、PDF、图片等)生成后,可自动发送给指定接收人,无需人工干预。
核心功能:
- - 自动检测工作区中的新文件
- 通过飞书消息发送文件附件
- 支持批量发送多个文件
- 可配置的文件类型过滤器和接收规则
快速开始
基本用法
当文件准备发送时:
javascript
// 单个文件
{
action: send,
filePath: /root/.openclaw/workspace/document.docx,
filename: document.docx,
message: 这是您的文件!,
target: useropenid
}
文件创建时自动发送
该技能提供了一个辅助脚本,用于监控新文件并自动发送:
bash
监控工作区并自动发送新文件
python3 scripts/auto
send.py --watch /root/.openclaw/workspace --recipient USEROPEN_ID
工作流程
步骤1:识别待发送文件
检查最近创建/修改的文件:
bash
列出最近10分钟内创建的文件
find /root/.openclaw/workspace -type f -mmin -10
步骤2:发送文件
使用带filePath参数的消息工具:
javascript
{
action: send,
filePath: <文件绝对路径>,
filename: <显示文件名>,
message: <可选消息>,
target: <接收人open_id>
}
参数说明:
- - filePath:文件的绝对路径(必填)
- filename:文件的显示名称(可选,默认为文件名)
- message:附带的文本消息(可选)
- target:接收人的open_id(省略时默认为当前用户)
步骤3:确认发送
检查响应以确认发送成功:
- - messageId:已发送消息的ID
- chatId:聊天/频道的ID
支持的文件类型
| 类型 | 扩展名 | 最大大小 |
|---|
| 文档 | .docx, .doc, .pdf | 30MB |
| 图片 |
.jpg, .png, .gif, .webp | 30MB |
| 表格 | .xlsx, .xls, .csv | 30MB |
| 压缩包 | .zip, .tar.gz | 30MB |
| 其他 | 任意 | 30MB |
批量发送
同时发送多个文件:
javascript
// 按顺序发送文件
for (const file of files) {
await message.send({
action: send,
filePath: file.path,
filename: file.name
});
}
配置
默认设置
- - 源目录:/root/.openclaw/workspace
- 最大文件大小:30MB(飞书限制)
- 自动接收人:当前对话用户
自定义接收人
发送给特定用户:
javascript
{
action: send,
target: oua65105519c863f8544fb22b40c468063, // 用户的openid
filePath: /path/to/file
}
脚本
scripts/auto_send.py
用于监控目录并自动发送文件的Python脚本。
用法:
bash
python3 scripts/auto_send.py [选项]
选项:
--watch PATH 要监控的目录(默认:workspace)
--recipient ID 目标接收人open_id
--pattern PATTERN 要匹配的文件模式(默认:*)
--once 发送现有文件后退出(不持续监控)
示例:
bash
监控并自动发送所有新PDF文件
python3 scripts/auto
send.py --pattern *.pdf --recipient USERID
一次性发送所有docx文件
python3 scripts/auto_send.py --pattern *.docx --once
故障排除
文件未找到
- - 确保文件路径为绝对路径
- 验证文件是否存在:ls -la <文件路径>
- 检查文件权限
发送失败
- - 验证文件大小小于30MB
- 检查接收人open_id是否正确
- 确保机器人有发送文件的权限
大文件处理
对于超过30MB的文件:
- 1. 压缩:zip -r output.zip largefile
- 分割:split -b 25M largefile part_
- 使用云存储并发送链接
最佳实践
- 1. 始终验证文件在发送前是否存在
- 使用描述性文件名以便更好地组织
- 批量处理相似文件以减少API调用
- 定期清理已发送文件以节省空间
- 记录已发送文件以便追踪(可选)
示例
示例1:发送生成的文档
用户:生成一份报告并发送给我
javascript
// 生成报告后
{
action: send,
filePath: /root/.openclaw/workspace/report_2024.docx,
filename: AnnualReport2024.docx,
message: 这是您的年度报告!
}
示例2:发送多个文件
用户:发送我工作区中的所有PDF文件
bash
查找并发送所有PDF文件
find /root/.openclaw/workspace -name *.pdf -exec \
python3 -c import sys; print(sys.argv[1]) {} \;
然后使用消息工具发送每个文件。
示例3:完成后自动发送
长时间运行的任务生成输出后:
javascript
// 任务完成,自动发送结果
{
action: send,
filePath: /root/.openclaw/workspace/output.pdf,
message: 任务完成!这是您的文件。
}