Files
clawbot/skills/temp-file-upload/SKILL.md

2.1 KiB
Raw Blame History

name, description
name description
temp-file-upload Upload files to Telegram by copying them into the macOS temporary directory (e.g., /var/folders/…/T/) so that the `message` tool accepts them; include steps to clean up afterward. Trigger when the user needs us to send images, audio, or other media files via Telegram but the workspace path isnt accepted.

Temp File Upload to Telegram

Purpose

Telegrams message tool refuses files that live in the workspace. The workaround is to copy the file into the Mac system temp directory ($TMPDIR, typically /var/folders/.../T/) before calling message.send. This skill captures that pattern so we can share downloads, exports, or generated assets reliably through Telegram.

Workflow

  1. Generate or download the file into the workspace or another location (browser download, script output, etc.).
  2. Copy into the temp directory: use mktemp to create a unique placeholder and copy the file there. Example:
    tmpfile=$(mktemp "${TMPDIR:-/tmp}/broimg_XXXXXX.png")
    cp ~/Downloads/my-image.png "$tmpfile"
    echo "$tmpfile"
    
    • Keep the copied path ($tmpfile) for the next step.
  3. Send via Telegram using the message tool:
    {
      "action": "send",
      "channel": "telegram",
      "media": "/var/folders/.../broimg_XXXXXX.png",
      "message": "Caption placeholder"
    }
    
    • Set asVoice: true only for voice notes.
    • Add a caption summarizing what the file is.
  4. Cleanup temp files after confirmation:

echo "Removing temp file" && rm -f "$tmpfile"

   - This avoids cluttering `/var/folders/...` with stale copies.
5. **Optional: Wrap in a script** when repeating the pattern (save inside `skills/temp-file-upload/scripts/copy-and-send.sh`).

## Notes
- Keep file names descriptive to make debugging easier (e.g., `broimg`, `brovoice`, `brodoc`).
- If the download lands in `~/Downloads`, move it before copying to `$TMPDIR` to avoid permission issues.
- When a user requests multiple files, repeat the copy + send steps for each file (dont rely on ZIP uploads unless explicitly asked).