通过机器人向 Telegram 用户发送不超过 50MB 的文件或笔记,支持本地、iCloud、相对路径或 Knowledge/ 路径,必要时自动压缩。
Send files to a Telegram user via bot, handling workspace path restrictions and Telegram's 50MB file size limit.
This skill enables an AI agent to send files from the local filesystem (including iCloud Drive paths) to a Telegram user through a bot account. It handles:
The agent must have:
If any of these are missing, ask the user before proceeding.
If the user didn't specify a path, ask them.
Accepted formats:
/Users/you/Documents/file.any~ expansion: ~/path/to/file.md, .txt, .pdf, .zip, images, etc.)bash
python3 skills/telegram-send-file/scripts/send_file.py "<source_path>" "<target_user_id>" [caption] [accountId]
Arguments:
ArgRequiredDefaultDescriptionsource_pathYes—Absolute path to the filetarget_user_idYes—Telegram chat ID (e.g. 123456789)captionNo""Text caption shown before the fileaccountIdNo(first bot)Bot accountId configured in OpenClaw
The script outputs key-value lines on stdout:
text
SEND_PATH=/tmp/xyz/file.md
SEND_FILENAME=file.md
TARGET=123456789
CAPTION=📄 My Document
ACCOUNT_ID=your_bot_account
READY
Extract SEND_PATH, TARGET, ACCOUNT_ID from the output.
json
{
"action": "send",
"channel": "telegram",
"target": "<TARGET from output>",
"accountId": "<ACCOUNT_ID from output>",
"filePath": "<SEND_PATH from output>",
"asDocument": true
}
Use filePath (absolute path), not path or relative paths.
After message tool returns ok: true, delete the temp file:
bash
rm <SEND_PATH>
rm -rf <parent_tmp_dir>
File sizeBehavior≤ 50MBCopied to tmp, sent as-is> 50MBAuto-zipped; sent if result ≤ 50MB> 50MB after zipPrints FAIL + suggestion; does not send
The suggestion will be either:
bash
python3 skills/telegram-send-file/scripts/send_file.py \
"/Users/you/Documents/report.pdf" \
"123456789" \
"📄 Report" \
"your_bot_account"
Works with any extension: .md, .txt, .pdf, .zip, .png, .jpg, .json, etc.
If a file exceeds 50MB, the script auto-zips it. If the zip is ≤ 50MB, it sends the zip automatically.
bash
python3 skills/telegram-send-file/scripts/send_file.py \
"/Users/you/path/to/file.png" \
"123456789" \
"🖼 Image" \
"another_bot_account"
The script exits with FAIL: Source file not found. Ask the user to verify the path.
If the file exists but cannot be read, the script will fail. Check file permissions.
Allowed. The script sends it normally.
Allowed. The script handles any file type, not just text.
Telegram handles filenames up to 255 chars. The script preserves the original basename.
zipfile module only)If sending fails:
ls -lh <path>ls <path>cp <path> /tmp/accountId is correct in OpenClaw configThis skill wraps the message tool's send action with file-document support. The workflow is:
message tool with the prepared absolute pathThe skill exists because: