agentleFS
leo-capvanoleo-capvano/telegram-skill/skills/telegram-bot/SKILL.md

telegram-bot

Skill1 starsChanged 7 months agoMITView on GitHub

Send text messages and files on Telegram, or read the latest updates received by the bot. Use this skill when the user asks to send content (text, reports, logs, screenshots) to a Telegram chat or channel, or to inspect incoming messages.

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 7 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before performing any operation, verify that the following environment variables are set in the environment:

    line 18
  2. Very specific:

    If TELEGRAM_BOT_TOKEN is not set, stop and ask the user to set it before proceeding.

    line 26
  3. Very specific:

    If the response contains "ok":true, the bot is configured correctly.

    line 42
  4. Very specific:

    If the user provides it explicitly (e.g.

    line 54
  5. Distinctive:

    If neither is available, ask the user for the chat ID before proceeding.

    line 56
  6. Distinctive:

    Always ask for explicit confirmation: before sending. Show:

    line 58
  7. Distinctive:

    If the user provides it explicitly, use it.

    line 86
  8. Distinctive:

    Verify that the file path exists and is accessible.

    line 89
  9. Distinctive:

    Ask for confirmation: before sending (file + recipient).

    line 90
  10. Distinctive:

    Update type (message, callback_query, etc.)

    line 136

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Telegram Bot

This skill allows the agent to interact with the Telegram Bot API via curl, using bash scripts included in the ./scripts/ directory.


Required Prerequisites

Before performing any operation, verify that the following environment variables are set in the environment:

VariableRequiredDescription
TELEGRAM_BOT_TOKEN✅ YesBot token obtained from @BotFather
TELEGRAM_DEFAULT_CHAT_ID❌ NoDefault numeric chat ID (e.g. your personal chat ID)

If TELEGRAM_BOT_TOKEN is not set, stop and ask the user to set it before proceeding.

Dependencies: The scripts require curl and jq to be installed.


Supported Actions

1. Verify bot token (getMe)

On first setup or if you suspect a token issue, run the verification command:

bash "./scripts/telegram-get-me.sh"

If the response contains "ok":true, the bot is configured correctly. If it contains "ok":false, inform the user that the token is invalid.


2. Send a text message

When to use: the user asks to send text to Telegram.

Steps:

  1. Determine the CHAT_ID:
    • If the user provides it explicitly (e.g. 123456789 or -100123456), use it.
    • Otherwise use $TELEGRAM_DEFAULT_CHAT_ID if set, notifying the user.
    • If neither is available, ask the user for the chat ID before proceeding.
  2. Always ask for explicit confirmation before sending. Show:
    • Recipient (chat ID)
    • Preview of the text
  3. Build the text. You can use HTML formatting (e.g. <b>bold</b>, <code>) or Markdown (e.g. **bold**, `code`).
  4. Run:
bash "./scripts/telegram-send-message.sh" "<CHAT_ID>" "<PARSE_MODE>" "<TEXT>"

Where <PARSE_MODE> is HTML, MarkdownV2, or leave it empty "" for plain text.

  1. Parse the JSON response:
    • "ok":true → message sent successfully. Inform the user.
    • "ok":false → report the description field to the user with corrective suggestions.

3. Send a document or file

When to use: the user asks to send a file (report, log, screenshot, etc.).

Steps:

  1. Determine the CHAT_ID:
    • If the user provides it explicitly, use it.
    • Otherwise use $TELEGRAM_DEFAULT_CHAT_ID if set, notifying the user.
    • If neither is available, ask the user for the chat ID before proceeding.
  2. Verify that the file path exists and is accessible.
  3. Ask for confirmation before sending (file + recipient).
  4. Run:
bash "./scripts/telegram-send-document.sh" "<CHAT_ID>" "<FILE_PATH>" "<CAPTION>"

<CAPTION> is optional: you can pass "" if you don't want a caption.

  1. Interpret the response as for text messages.

Note: for files larger than 50 MB, the standard Bot API is not supported. Inform the user.


4. Send an image

When to use: the user asks to send an image (PNG, JPG, etc.).

Steps: Same as sending a document. Determine chat ID, verify the file exists, ask for confirmation, then run:

bash "./scripts/telegram-send-photo.sh" "<CHAT_ID>" "<FILE_PATH>" "<CAPTION>"

Note: Images larger than 10 MB are not supported. Use telegram-send-document.sh instead for large images.


5. Read the latest updates (getUpdates)

When to use: the user wants to inspect incoming messages from the bot.

Important warning: getUpdates is incompatible with webhooks. If a webhook is active, this call will return an error. Inform the user before proceeding.

bash "./scripts/telegram-get-updates.sh" "<OFFSET>" "<LIMIT>"
  • <OFFSET>: use "" to read all updates, or update_id + 1 of the last read update to scroll the queue.
  • <LIMIT>: number of updates to read (1–100). Recommended default: 20.

Parse the returned JSON and list in readable form:

  • update_id
  • Update type (message, callback_query, etc.)
  • Sender (name + username if present)
  • Message text or content type

Security Guidelines

  • ❌ Do not derive tokens or secrets from the conversation context.
  • ❌ Do not perform bulk sends or automatic loops without explicit human oversight.
  • ✅ For batch operations, show a summary and ask for approval before starting.

Common Error Handling

Telegram ErrorLikely CauseSolution
401 UnauthorizedWrong or revoked tokenCheck TELEGRAM_BOT_TOKEN
400 Bad Request: chat not foundWrong chat ID or bot not in chatVerify chat ID; add bot to the chat
403 ForbiddenBot banned from chatUse another chat or add the bot
429 Too Many RequestsRate limit reachedWait the indicated number of seconds
TELEGRAM_BOT_TOKEN not setMissing environment variableSet TELEGRAM_BOT_TOKEN in the environment

Quick Examples

Send a message to the default chat:

send "Deploy completed successfully" to the default Telegram chat

Send a log file:

send the file ./logs/app.log on Telegram to chat ID 123456789

Read the last 10 messages:

show me the last 10 updates received by the bot

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.