Telegram logo

Telegram

OrganizationPopular
bubbuild
telegram

Telegram Bot skill for sending and editing Telegram messages via Bot API. Use when Bub needs to: (1) Send a message to a Telegram user/group/channel, (2) Reply to a specific Telegram message with reply_to_message_id, (3) Edit an existing Telegram message, or (4) Push proactive Telegram notifications. Prefer rich formatted messages (headings, lists, tables, blockquotes, math, collapsible details, captioned media) over plain markdown whenever the content is more than one short paragraph.

Overview

Publisherbubbuild
Repositorybub
Skill nametelegram
Stars
1.7K
Forks
167
Bundled files
3
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by bubbuild on GitHub. Read the source before you install it.

Installation

Install the Telegram AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/bubbuild/bub/tree/main/src/skills/telegram
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bubbuild/bub.git /tmp/bub
mkdir -p .claude/skills
cp -r /tmp/bub/src/skills/telegram .claude/skills/telegram
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Telegram in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Telegram on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Telegram is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Telegram Skill

Agent-facing execution guide for Telegram outbound communication.

Env vars:

  • BUB_TELEGRAM_TOKEN=${config.telegram.token}

Required Inputs

Collect these before execution:

  • chat_id (required)
  • message_id (required for edit or reply)
  • message content (required for send/edit)
  • reply_to_message_id (required when you need a threaded reply)

Rich Messages (Bot API 10.1+, June 2026) — PREFERRED

For any message that benefits from structured formatting — headings, bullet/numbered lists, tables, blockquotes, collapsible <details>, captioned media, math blocks, code blocks with language hints, or mixed media — use the dedicated telegram_rich.py script with rich-html-style markup. This is the first-choice path; fall back to plain markdown (telegram_send.py) only for short single-paragraph replies.

The Rich Message API uses sendRichMessage and editMessageText with a rich_message payload. Exactly one of html or markdown must be supplied. Supported HTML tags include <b>, <i>, <u>, <s>, <tg-spoiler>, <code>, <pre>, <mark>, <sub>, <sup>, <h1>-<h6>, <p>, <ul>/<ol>/<li>, <blockquote>, <aside>, <details>/<summary>, <table>, <figure>/<figcaption>, <img>/<video>/<audio>, <tg-collage>, <tg-slideshow>, <tg-map>, <tg-math>, <tg-math-block>, <tg-reference>, <tg-emoji>, <tg-time>. Full reference: https://core.telegram.org/bots/api#rich-html-style

bash
# Send rich message (HTML)
uv run ./scripts/telegram_rich.py \
  --chat-id <CHAT_ID> \
  --html "<h2>Title</h2><p>Body with <b>bold</b> and <code>code</code>.</p>"

# Send rich message (HTML from heredoc via file)
uv run ./scripts/telegram_rich.py \
  --chat-id <CHAT_ID> \
  --html-file /tmp/payload.html \
  --reply-to <MESSAGE_ID>

# Send rich message (Markdown instead of HTML)
uv run ./scripts/telegram_rich.py \
  --chat-id <CHAT_ID> \
  --markdown "## Title\n\n- item one\n- item two"

# Edit an existing message to become a rich message
uv run ./scripts/telegram_rich.py \
  --chat-id <CHAT_ID> \
  --edit <MESSAGE_ID> \
  --html "<p>Updated content.</p>"

For multi-line rich HTML, prefer --html-file over passing the payload on the command line to avoid shell escaping pitfalls. The script reads the file as UTF-8 and strips a single trailing newline.

Execution Policy

  1. If handling a direct user message in Telegram and message_id is known, send a reply message (--reply-to).
  2. If source metadata says sender is a bot (sender_is_bot=true), do not use reply mode, but send a normal message and prefix content with @<sender_username> (or the provided source username). If the user doesn't have a username, use --source-user-id to mention via tg://user?id= link.
  3. For long-running tasks, optionally send one progress message, then edit that same message for final status.
  4. ALWAYS pass message content via stdin using heredoc pipe and --message - (or --text -). NEVER embed message text directly in shell arguments — special characters like ', ", $, ! will be mangled or cause syntax errors.
  5. Prefer telegram_rich.py (rich-html-style) over telegram_send.py for anything beyond a single short paragraph. See the "Rich Messages" section above.

Bot to co-Bot Communication

In Telegram groups, communicate with another bot using only these patterns:

  1. Reply directly to the other bot's message when message_id is available.
  2. Use an explicit command mention such as /command@OtherBot when you need to invoke that bot intentionally.
  3. Do not assume free-form group text will reach another bot.

Active Response Policy

When this skill is in scope, prefer proactive and timely Telegram updates:

  • Send an immediate acknowledgment for newly assigned tasks
  • Send progress updates for long-running operations using message edits
  • Send completion notifications when work finishes
  • Send important status or failure notifications without waiting for follow-up prompts
  • If execution is blocked or fails, send a problem report immediately with cause, impact, and next action

Recommended pattern:

  1. Send a short acknowledgment reply
  2. Continue processing
  3. If blocked, edit or send an issue update immediately
  4. Edit the acknowledgment message with final result when possible

Voice Message Policy

When the inbound Telegram message is voice:

  1. Transcribe the voice input first (use STT skill if available)
  2. Prepare response content based on transcription
  3. Prefer voice response output (use TTS skill if available)
  4. If voice output is unavailable, send a concise text fallback and state limitation

Reaction Policy

When an inbound Telegram message warrants acknowledgment but does not merit a full reply, use a Telegram reaction as the response. But when any explanation or details are needed, use a normal reply instead.

Command Templates

Paths are relative to this skill directory.

bash
# Send message (ALWAYS use heredoc stdin, never inline text in arguments)
cat << 'EOF' | uv run ${SKILL_DIR}/scripts/telegram_send.py --chat-id <CHAT_ID> --token "$BUB_TELEGRAM_TOKEN" --message -
Your message content here.
Special characters are safe: $100, "quotes", 'apostrophes', !exclamation
EOF

# Reply to a specific message
cat << 'EOF' | uv run ${SKILL_DIR}/scripts/telegram_send.py --chat-id <CHAT_ID> --token "$BUB_TELEGRAM_TOKEN" --reply-to <MESSAGE_ID> --message -
Reply content here.
EOF

# Source message sender is bot: no direct reply, use @username style
cat << 'EOF' | uv run ${SKILL_DIR}/scripts/telegram_send.py --chat-id <CHAT_ID> --token "$BUB_TELEGRAM_TOKEN" --source-is-bot --source-username <USERNAME> --message -
Message to a bot using @username mention.
EOF

# Source message sender is bot without username: use tg://user?id= link
cat << 'EOF' | uv run ${SKILL_DIR}/scripts/telegram_send.py --chat-id <CHAT_ID> --token "$BUB_TELEGRAM_TOKEN" --source-is-bot --source-user-id <USER_ID> --source-display-name "Display Name" --message -
Message to a user/bot using tg://user?id= mention.
EOF

# Edit an existing message
cat << 'EOF' | uv run ${SKILL_DIR}/scripts/telegram_edit.py --chat-id <CHAT_ID> --token "$BUB_TELEGRAM_TOKEN" --message-id <MESSAGE_ID> --text -
Updated content here.
EOF

When sending message to a bot, either use --reply-to argument or pass --source-is-bot with --source-username otherwise the bot will not receive the message.

For other actions that not covered by these scripts, use curl to call Telegram Bot API directly with the provided token.

Script Interface Reference

telegram_rich.py (preferred for structured messages)

  • --chat-id, -c: required
  • --html: rich message content as HTML
  • --html-file: read rich message HTML from a file (preferred for multi-line payloads)
  • --markdown: rich message content as Markdown
  • --markdown-file: read rich message Markdown from a file
  • --rtl: render right-to-left
  • --skip-entity-detection: skip URL/email/mention auto-detection
  • --reply-to, -r: optional message ID to reply to
  • --disable-notification: send silently
  • --edit MESSAGE_ID: edit an existing message instead of sending
  • --token, -t: optional (normally not needed)

telegram_send.py

  • --chat-id, -c: required, supports comma-separated ids
  • --message, -m: required (use - to read from stdin)
  • --reply-to, -r: optional
  • --token, -t: optional (normally not needed)
  • --source-is-bot: optional flag, disables reply mode and adds mention prefix
  • --source-username: optional, uses @username style mention when set
  • --source-user-id: optional, uses tg://user?id= link mention when username is not available
  • --source-display-name: optional, display name for user ID mention (defaults to "User")

telegram_edit.py

  • --chat-id, -c: required
  • --message-id, -m: required
  • --text, -t: required (use - to read from stdin)
  • --token: optional (normally not needed)

Bot to co-Bot Communication

In Telegram groups, communicate with another bot using only these patterns:

  1. Reply directly to the other bot's message when message_id is available.
  2. Use an explicit command mention such as /command@OtherBot when you need to invoke that bot intentionally.
  3. Do not assume free-form group text will reach another bot.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Telegram AI skill do?

Telegram Bot skill for sending and editing Telegram messages via Bot API. Use when Bub needs to: (1) Send a message to a Telegram user/group/channel, (2) Reply to a specific Telegram message with reply_to_message_id, (3) Edit an existing Telegram message, or (4) Push proactive Telegram notifications. Prefer rich formatted messages (headings, lists, tables, blockquotes, math, collapsible details, captioned media) over plain markdown whenever the content is more than one short paragraph.

Why use Telegram on TypingMind?

Because you install it once and use it with any model. Telegram is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Telegram in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/bubbuild/bub/tree/main/src/skills/telegram. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Telegram?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Telegram?

As many as you like. As long as a model supports skills, you can use Telegram with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Telegram AI skill free?

Yes. It is published on GitHub by bubbuild under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇