【Side Project 模塊 #16】告別在 10 個分區裡手動找筆記:我如何為 Telegram AI 知識庫實作 Forum Topic 自動深度跳轉(Deep Link)?[Side Project #16] Stop Digging Through 10 Topics: Building Direct Telegram Forum Deep Links for Seamless AI Navigation
做 Telegram 知識庫 Bot,很多工程師只在乎後端能不能把筆記發進分區。但使用者在原群組看到「分析完成」後,還得手動退出、點進話題、滑到底部找訊息——這 4 個動作徹底打斷了注意力。看我如何用一行 Deep Link 格式與 Inline Button,實現一鍵秒開目標分區並精準定位該則筆記。
Most engineers stop when a bot successfully drops an AI summary into a Telegram forum topic. But forcing users to exit, browse topics, and scroll down breaks flow. Here is how I constructed direct private deep links and inline buttons to achieve one-tap instant message positioning.
01 // The Friction: Why "Filed to Topic" Ruins the Reading Experience
When your knowledge base grows to 10+ topics with dozens of daily video summaries, users posting a link expect immediate payoff—not a game of hide-and-seek across channels.
Multi-step navigation: Exit topic -> Scan topic list -> Tap into topic -> Scroll to bottom.
Attention leakage: Notification badges in other topics distract users during navigation.
Broken loop: Static text gives no direct affordance to inspect or reply to the AI summary.
02 // The Technical Spec: Telegram Supergroup & Forum Topic Deep Links
Public channel links are straightforward (t.me/name/123). Private supergroups with forum topics follow a specific URL schema:
def build_telegram_post_link(chat_id: int, thread_id: int, message_id: int) -> str:
"""
Constructs a direct jump link to a message inside a Telegram supergroup / forum topic.
Telegram private supergroup chat_ids start with -100 (e.g. -1004383208435).
Format for topics: https://t.me/c/<clean_cid>/<thread_id>/<message_id>
"""
if not message_id:
return ""
# 去除 Telegram Supergroup 固有的 -100 或 - 前綴
clean_cid = str(chat_id).replace("-100", "").replace("-", "")
# 若存在話題分區 (thread_id > 1),拼接 3 段式路徑;否則為一般訊息
if thread_id and int(thread_id) > 1:
return f"https://t.me/c/{clean_cid}/{thread_id}/{message_id}"
return f"https://t.me/c/{clean_cid}/{message_id}"
Three critical details: strip the -100 prefix, insert the thread_id as the middle path segment, and immediately capture the returned message_id from the Telegram API call.
Upon completing audio transcription, chart rendering, and Gemini summarization, the bot updates the original prompt message with both inline text and an action button:
▲ 圖解架構:Telegram Knowledge Ingestion & Deep Link Jump Workflow
Traditional Notice vs. Deep Link Jump Comparison
Criterion
Legacy Text Notice
Forum Deep Link Jump
Navigation Steps
4 actions (Exit -> Search -> Enter -> Scroll)
1 tap on the direct action button
Locate Latency
5-8 seconds manual searching
Instant (<0.3s native view transition)
Attention Retention
Easily distracted by other unread badges
100% focused on current context
Cross-Platform Support
Manual cognitive burden across devices
Smooth client jump on iOS/Android/Mac/PC
Perceived UX
Functional but cumbersome
Frictionless and delightful
What happens if a non-member clicks this private deep link?
The t.me/c/ format enforces native Telegram privacy. Non-members receive a "Chat not found" or permission prompt, ensuring zero data leakage.
Does this deep link work reliably on Telegram Desktop for macOS and Windows?
Yes. Telegram Desktop smoothly switches the channel view to the target topic and highlights the specific message bubble instantly.
Looking to Build Frictionless Telegram AI Workflows for Your Business?
True AI value lies in respecting the user's attention. Let's chat about your workflow automation goals and design lightweight, delightful tools together.