Tg Rich Streaming logo

Tg Rich Streaming

Community
serejaris
tg-rich-streaming

Use when streaming LLM or AI-generated replies to Telegram in real time (ChatGPT-style progressive output in a bot), showing a model thinking indicator, or delivering token-by-token text as an animated rich message draft that finalizes into a permanent message.

Overview

Publisherserejaris
Repositorytelegram-skills
Skill nametg-rich-streaming
Stars
35
Forks
4
Bundled files
1
LicenseMIT
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.

  • 1 bundled files

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

  • Open source

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

Installation

Install the Tg Rich Streaming 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/serejaris/telegram-skills/tree/main/skills/tg-rich-streaming
  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/serejaris/telegram-skills.git /tmp/telegram-skills
mkdir -p .claude/skills
cp -r /tmp/telegram-skills/skills/tg-rich-streaming .claude/skills/tg-rich-streaming
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Tg Rich Streaming 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 Tg Rich Streaming 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 Tg Rich Streaming 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.

tg-rich-streaming

Stream AI-generated text into a Telegram private chat with native draft animation and a "thinking" indicator — the same UX as ChatGPT or Claude, directly inside the bot.

Sending requires network access to api.telegram.org and TELEGRAM_BOT_TOKEN. sendRichMessageDraft works only with a private integer chat_id. Bot API 10.2 also permits direct InputRichMessage.blocks; the draft lifecycle below is unchanged.

Core pattern

Four mandatory steps. Skip step 3 and the draft disappears after ~30 seconds.

Step 1 — open draft with Thinking block

Send the first sendRichMessageDraft immediately after the LLM call starts. draft_id is any non-zero integer you generate once per response; keep it for all updates. RichBlockThinking signals the model is working.

POST /sendRichMessageDraft
{
  "chat_id": <integer>,          // private chat only — no @username
  "draft_id": 42,
  "rich_message": {
    "markdown": "<tg-thinking>Thinking…</tg-thinking>"
  }
}

Rich HTML tags (like <tg-thinking>) are valid pass-through inside the markdown field — spec explicitly allows HTML tags in Rich Markdown.

RichBlockThinking is only valid in sendRichMessageDraft. It is never stored in a Message.

Step 2 — update draft as tokens arrive

Call sendRichMessageDraft again with the same draft_id each time you have enough new text. The client animates the transition.

Throttle: send at most once every 1–2 seconds. The draft is ephemeral (~30 s window) — keep sending updates or move to step 3 before the window closes.

Drop the Thinking block from the first update that contains real content.

# pseudocode — generic async LLM stream

draft_id = generate_nonzero_id()
accumulated = ""
last_sent = 0

send_draft(chat_id, draft_id, thinking_markdown())   # step 1

for chunk in llm.stream(prompt):
    accumulated += chunk.text
    now = time.monotonic()
    if now - last_sent >= 1.5:                        # throttle
        send_draft(chat_id, draft_id, accumulated)
        last_sent = now

finalize(chat_id, accumulated)                        # step 3 — mandatory

Step 3 — finalize with sendRichMessage (mandatory)

After the LLM stream ends, call sendRichMessage. This creates the permanent message. If you skip this, the draft vanishes.

POST /sendRichMessage
{
  "chat_id": <integer>,
  "rich_message": {
    "markdown": "<full generated text>"
  }
}

Step 4 — edits after finalization

Use editMessageText with the rich_message parameter to update the permanent message later (corrections, appended content, etc.).

POST /editMessageText
{
  "chat_id": <integer>,
  "message_id": <id from step 3 response>,
  "rich_message": {
    "markdown": "<revised text>"
  }
}

text and rich_message are mutually exclusive in editMessageText — use exactly one.


Pitfalls

TrapWhat happensFix
Skipped sendRichMessage after stream endsDraft disappears after ~30 s, no permanent messageAlways call sendRichMessage with full text as last step
chat_id is a String or @usernamesendRichMessageDraft returns errorOnly Integer chat_id supported for drafts; fall back to sendMessage + editMessageText in groups/channels
Sending a draft update every tokenFlood / rate limit, poor animationBatch tokens, send at most every 1–2 s
RichBlockThinking in sendRichMessageNot stored in Message; spec prohibits itRemove Thinking block before finalization
Partial Markdown mid-streamUnclosed ``` or ** renders brokenEither send complete blocks only, or use raw text during streaming and apply Markdown only at finalization
30-second window expires mid-streamDraft goneIf stream is slow, send a keep-alive draft update (even unchanged text) before the window closes

Group / channel fallback

sendRichMessageDraft is private-chat only. For groups and channels:

  1. Send initial sendMessage with "⌛ Generating…" placeholder.
  2. Edit with editMessageText (rich_message) when done.

No real-time animation, but the final message is rich-formatted.


Request reference

sendRichMessageDraft  POST /bot<TOKEN>/sendRichMessageDraft
  chat_id        Integer   required — private chat only
  draft_id       Integer   required — non-zero; same id = animated update
  rich_message   InputRichMessage   required

sendRichMessage       POST /bot<TOKEN>/sendRichMessage
  chat_id        Integer or String   required
  rich_message   InputRichMessage    required
  → returns Message (use .message_id for edits)

editMessageText       POST /bot<TOKEN>/editMessageText
  chat_id        Integer or String
  message_id     Integer
  rich_message   InputRichMessage    (mutually exclusive with "text")

InputRichMessage fields: exactly one of html, markdown, or blocks, optional is_rtl, optional skip_entity_detection.


Related

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 Tg Rich Streaming AI skill do?

Use when streaming LLM or AI-generated replies to Telegram in real time (ChatGPT-style progressive output in a bot), showing a model thinking indicator, or delivering token-by-token text as an animated rich message draft that finalizes into a permanent message.

Why use Tg Rich Streaming on TypingMind?

Because you install it once and use it with any model. Tg Rich Streaming 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 Tg Rich Streaming in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/serejaris/telegram-skills/tree/main/skills/tg-rich-streaming. 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 Tg Rich Streaming?

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 Tg Rich Streaming?

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

Is the Tg Rich Streaming AI skill free?

Yes. It is published on GitHub by serejaris under the MIT 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 👇