Tg Rich Streamingのロゴ

Tg Rich Streaming

コミュニティ
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.

概要

公開者serejaris
リポジトリtelegram-skills
スキル名tg-rich-streaming
スター
35
フォーク
4
同梱ファイル
1
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    serejarisがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Tg Rich Streaming」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/serejaris/telegram-skills/tree/main/skills/tg-rich-streaming
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでTg Rich Streamingを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にTg Rich Streamingを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Tg Rich Streamingは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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.

TypingMindでTg Rich Streamingを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Tg Rich Streamingはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにTg Rich Streamingをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/serejaris/telegram-skills/tree/main/skills/tg-rich-streamingを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Tg Rich Streamingを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Tg Rich Streamingで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもTg Rich Streamingを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Tg Rich Streaming」は無料ですか?

はい。serejarisがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇