๐ค Telegram File Sender
/install tg-file-sender
๐ค Telegram File Sender
Send local files directly to a Telegram chat using the Bot API. The bot token is read from environment variable TG_BOT_TOKEN โ never hardcoded or logged.
Prerequisites
TG_BOT_TOKENenvironment variable must be setcurlmust be available- The target chat must have started a conversation with the bot
Usage
Step 1: Resolve File Path
Accept a file path from the user. Resolve it relative to the workspace:
FILE_PATH="\x3Cworkspace>/\x3Cuser-provided-path>"
Security rules:
- Resolve to absolute path using
realpath - Reject if path does not start with the workspace root
- Reject if file does not exist
- Reject if file is a symlink (avoid directory traversal)
- Reject if file size > 50 MB (Telegram document limit)
Step 2: Detect File Type
Use the file extension to determine the appropriate Telegram method:
| Extension | Method | Caption support |
|---|---|---|
.jpg .jpeg .png .gif .webp |
sendPhoto |
โ Yes |
.mp4 .mov .avi .webm |
sendVideo |
โ Yes |
.mp3 .ogg .wav .flac |
sendAudio |
โ Yes |
Others (.xlsx, .pdf, .md, .zip, etc.) |
sendDocument |
โ Yes |
Step 3: Send via Bot API
BOT_TOKEN="$TG_BOT_TOKEN"
CHAT_ID="\x3Ctarget chat ID>"
FILE_PATH="\x3Cresolved absolute path>"
CAPTION="\x3Coptional description>"
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
-F chat_id="$CHAT_ID" \
-F document=@"$FILE_PATH" \
-F caption="$CAPTION"
For photos:
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
-F chat_id="$CHAT_ID" \
-F photo=@"$FILE_PATH" \
-F caption="$CAPTION"
Step 4: Handle Response
Parse the JSON response:
- If
ok: trueโ confirm delivery: "โ ๆไปถๅทฒๅ้" - If
ok: falseโ report thedescriptionfield to the user
Privacy & Security Guidelines
- Token protection: Never log, echo, or display the bot token value. Use
$TG_BOT_TOKENonly in the API call URL. - Path traversal prevention: Always resolve with
realpathand verify the result starts with the workspace root. - No content logging: Do not log file contents or read file contents for any purpose beyond sending.
- Size limit: Enforce 50 MB maximum (Telegram Bot API limit for documents).
- User confirmation: For files > 10 MB, warn the user about size before sending.
- Chat ID: Use the
chat_idfrom the session context. Never prompt the user for a chat ID. - Ephemeral files: If the file is in
/tmp/, clean up after sending.
Behavior Rules
- If
TG_BOT_TOKENis unset โ tell the user: "่ฏทๅ ่ฎพ็ฝฎ TG_BOT_TOKEN ็ฏๅขๅ้" - If the file doesn't exist โ "ๆไปถไธๅญๅจ๏ผ่ฏทๆฃๆฅ่ทฏๅพ"
- If the file is outside workspace โ "่ทฏๅพไธๅจๅทฅไฝ็ฎๅฝ่ๅดๅ ๏ผๅทฒๆ็ป"
- If the file exceeds 50 MB โ "ๆไปถ่ถ ่ฟ 50MB๏ผTelegram ไธๆฏๆๅ้"
- If the API returns an error โ show the error description to the user
๐ค Telegram ๆไปถๅ้ๅจ
้่ฟ Telegram Bot API ๅฐๆฌๅฐๆไปถ็ดๆฅๅ้ๅฐ่ๅคฉ็ชๅฃใBot Token ไป็ฏๅขๅ้ TG_BOT_TOKEN ่ฏปๅ๏ผ็ปไธ็กฌ็ผ็ ๆๅๅ
ฅๆฅๅฟใ
ๅๆๆกไปถ
- ้่ฎพ็ฝฎ
TG_BOT_TOKEN็ฏๅขๅ้ - ้ๅฎ่ฃ
curl - ็ฎๆ ่ๅคฉๅฏน่ฑก้ๅทฒไธ bot ๆ่ฟๅฏน่ฏ
ไฝฟ็จๆนๆณ
็ฌฌไธๆญฅ๏ผ่งฃๆๆไปถ่ทฏๅพ
ๆฅๆถ็จๆทๆไพ็่ทฏๅพ๏ผ็ธๅฏนไบๅทฅไฝ็ฎๅฝ่งฃๆ๏ผ
FILE_PATH="\x3Cworkspace>/\x3C็จๆทๆไพ็่ทฏๅพ>"
ๅฎๅ จๆฃๆฅ๏ผ
- ็จ
realpath่งฃๆไธบ็ปๅฏน่ทฏๅพ - ๆ็ปไธๅจๅทฅไฝ็ฎๅฝ่ๅดๅ ็่ทฏๅพ
- ๆ็ปไธๅญๅจ็ๆไปถ
- ๆ็ป็ฌฆๅท้พๆฅ๏ผ้ฒๆญข็ฎๅฝ็ฉฟ่ถ๏ผ
- ๆ็ปๅคงไบ 50MB ็ๆไปถ
็ฌฌไบๆญฅ๏ผ่ฏๅซๆไปถ็ฑปๅ
ๆ นๆฎๆฉๅฑๅ้ๆฉๅ้ๆนๅผ๏ผ
| ๆฉๅฑๅ | ๆนๆณ | ๆฏๆๆ ้ข |
|---|---|---|
.jpg .jpeg .png .gif .webp |
sendPhoto |
โ ๆฏ |
.mp4 .mov .avi .webm |
sendVideo |
โ ๆฏ |
.mp3 .ogg .wav .flac |
sendAudio |
โ ๆฏ |
ๅ
ถไป๏ผ.xlsx .pdf .md .zip ็ญ๏ผ |
sendDocument |
โ ๆฏ |
็ฌฌไธๆญฅ๏ผ้่ฟ Bot API ๅ้
BOT_TOKEN="$TG_BOT_TOKEN"
CHAT_ID="\x3C็ฎๆ ่ๅคฉID>"
FILE_PATH="\x3C่งฃๆๅ็็ปๅฏน่ทฏๅพ>"
CAPTION="\x3Cๅฏ้ๆ่ฟฐ>"
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
-F chat_id="$CHAT_ID" \
-F document=@"$FILE_PATH" \
-F caption="$CAPTION"
็ฌฌๅๆญฅ๏ผๅค็ๅๅบ
่งฃๆ JSON ๅๅบ๏ผ
ok: trueโ ็กฎ่ฎคๅ้๏ผ"โ ๆไปถๅทฒๅ้"ok: falseโ ๅ็จๆทๅฑ็คบdescriptionๅญๆฎตไธญ็้่ฏฏไฟกๆฏ
้็งไธๅฎๅ จ่ง่
- Token ไฟๆค๏ผ ็ปไธๆๅฐใ่ฎฐๅฝๆๆพ็คบ bot tokenใไป
ๅจ API ่ฐ็จ URL ไธญไฝฟ็จ
$TG_BOT_TOKEN - ่ทฏๅพ็ฉฟ่ถ้ฒๆค๏ผ ๅง็ป็จ
realpath่งฃๆ๏ผ้ช่ฏ็ปๆไปฅๅทฅไฝ็ฎๅฝๅผๅคด - ไธ่ฎฐๅฝๅ ๅฎน๏ผ ไธ่ฏปๅๆ่ฎฐๅฝๆไปถๅ ๅฎน
- ๅคงๅฐ้ๅถ๏ผ ไธ้ 50MB
- ๅคงๆไปถๆ้๏ผ ๅคงไบ 10MB ๆถๆ้็จๆท
- Chat ID๏ผ ไปไผ่ฏไธไธๆ่ทๅ๏ผไธๅ็จๆท่ฏข้ฎ
- ไธดๆถๆไปถ๏ผ /tmp ไธ็ๆไปถๅ้ๅๆธ ็
่กไธบ่งๅ
TG_BOT_TOKENๆช่ฎพ็ฝฎ โ "่ฏทๅ ่ฎพ็ฝฎ TG_BOT_TOKEN ็ฏๅขๅ้"- ๆไปถไธๅญๅจ โ "ๆไปถไธๅญๅจ๏ผ่ฏทๆฃๆฅ่ทฏๅพ"
- ่ทฏๅพไธๅจๅทฅไฝ็ฎๅฝๅ โ "่ทฏๅพไธๅจๅทฅไฝ็ฎๅฝ่ๅดๅ ๏ผๅทฒๆ็ป"
- ๆไปถ่ถ ่ฟ 50MB โ "ๆไปถ่ถ ่ฟ 50MB๏ผTelegram ไธๆฏๆๅ้"
- API ่ฟๅ้่ฏฏ โ ๅฐ้่ฏฏๆ่ฟฐๅฑ็คบ็ป็จๆท
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install tg-file-sender - After installation, invoke the skill by name or use
/tg-file-sender - Provide required inputs per the skill's parameter spec and get structured output
What is ๐ค Telegram File Sender?
Send local files directly to Telegram chat. Supports documents, photos, and other media types. Use when user says: "send this file to me", "send to telegram"... It is an AI Agent Skill for Claude Code / OpenClaw, with 96 downloads so far.
How do I install ๐ค Telegram File Sender?
Run "/install tg-file-sender" in the OpenClaw or Claude Code chat to install it in one step โ no extra setup required.
Is ๐ค Telegram File Sender free?
Yes, ๐ค Telegram File Sender is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does ๐ค Telegram File Sender support?
๐ค Telegram File Sender is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created ๐ค Telegram File Sender?
It is built and maintained by shake27 (@bustes01); the current version is v1.0.0.