Telegram Echo
Send a one-shot text message to a Telegram chat via the Bot API.
The LLM picks the right script invocation and reports the result. It does
NOT write the curl, JSON, or auth header itself — that's scripts/echo.sh's
job.
When to use
User asks to send / echo / reply / post a Telegram message and gives you both a chat target and the text to send.
Example user requests:
- "Echo 'hello world' back to chat 12345"
- "Send 'meeting at 3' to my Telegram"
- "Reply to chat -1001234567 with 'on it'"
If the user has NOT supplied a chat id and the surrounding context doesn't carry one (e.g. an incoming Telegram update), ask for it before invoking the script.
How
Run:
bash scripts/echo.sh
Examples the LLM should emit verbatim:
bash scripts/echo.sh 12345 "hello world" bash scripts/echo.sh -1001234567890 "on it" bash scripts/echo.sh 12345 "multi word message with $special chars"
Always quote the text. The script passes it straight to the Bot API.
Errors
Script exit codes:
| Exit | Meaning | What to tell the user |
|---|---|---|
| 0 | Sent | Confirm with the message id from stdout. |
| 1 | Missing arg | "I need a chat id and a message to send." |
| 2 | Missing $TELEGRAM_BOT_TOKEN | "No Telegram bot is wired up for this agent yet." |
| 3 | Telegram API error | Relay the API error text from stderr. |
Anything else: relay stderr to the user.
Don't do this
🔴 Don't construct the curl call yourself. 🔴 Don't read $TELEGRAM_BOT_TOKEN directly — the script handles it. 🔴 Don't retry on exit=3 without checking the error; it's usually a bad chat id or revoked token.
🟢 Do call the script. That's the whole point.