狀態:線上運行中 ── AI 創業家實況 (LINLINK.COM) STATUS: ONLINE ── AI ENTREPRENEUR (LINLINK.COM) 線上運行中 ONLINE
← 返回文章列表 ← Back to Articles
Telegram 自動化與工作流 Telegram 自動化與工作流
· 2026-11-18 ·

【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.

📑 顯示/隱藏文章目錄 📑 Show / Hide Table of Contents
  1. 01 // 痛點還原:為什麼「已整理至某分區」是一句不負責任的廢話? 01 // The Friction: Why "Filed to Topic" Ruins the Reading Experience
  2. 02 // 底層規範:Telegram Supergroup 與 Forum Topic 的私有 Deep Link 結構 02 // The Technical Spec: Telegram Supergroup & Forum Topic Deep Links
  3. 03 // 雙軌閉環設計:超連結文字 + Inline Keyboard 一鍵直達 03 // Dual-Channel UI: Hyperlinks & Inline Keyboard Buttons

01 // 痛點還原:為什麼「已整理至某分區」是一句不負責任的廢話?

當你的 Telegram 知識庫累積了 8~10 個 Topic 分區,且每天有數十則自動抓取的 YouTube 影片、Threads 貼文與財經圖表時,使用者在主要對話貼上連結後,最核心的訴求是「立刻看見結論」,而不是進行一場資料夾捉迷藏。

  1. 動作繁瑣:退出當前話題 ➔ 在論壇話題列表肉眼搜尋目標分區 ➔ 點擊進入 ➔ 往下滑動找到剛才生成的筆記。
  2. 注意力中斷:在切換分區的過程中,很容易被其他主題的新未讀紅點吸引,忘記自己原本要看什麼。
  3. 缺少閉環:原訊息只是一個靜態通知,無法在第一時間驗證生成結果好壞或進行後續討論。

如果是公開頻道(Public Channel),訊息跳轉連結很簡單:https://t.me/username/123。但在私有超大群組(Supergroup)和啟用了論壇話題(Forum Topics)的群組中,必須遵循 Telegram 特殊的內部 URL 規範:

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}"

這裡的關鍵是三件事:第一、chat_id 必須剔除 -100,變成純數字;第二、必須將目標話題的 thread_id 擺在中段;第三、在非同步發送完成的當下,即時補獲 Telegram API 回傳的 message_id,而不是射後不理。

03 // 雙軌閉環設計:超連結文字 + Inline Keyboard 一鍵直達

當後端背景任務完成音訊轉譯、K 線圖擷取與 Gemini 摘要發布後,Bot 立即回頭編輯原對話的狀態訊息,注入「文字內聯跳轉」與「高對比按鈕」:

# 更新原對話狀態,附帶跳轉連結與按鈕
post_url = build_telegram_post_link(post_chat_id, post_thread_id, post_msg_id)
jump_text = f'\n👉 <a href="{post_url}">點此直接跳轉查看分析文 ↗</a>' if post_url else ""

reply_markup = {
    "inline_keyboard": [
        [{"text": f"📖 前往查看『{cat}』分析文 ↗", "url": post_url}]
    ]
} if post_url else None

tg_bot.edit_message(
    chat_id=chat_id,
    message_id=status_msg_id,
    text=f"✅ <b>影片分析完成!</b>\n📁 已整理發送至主題分區:『<b>{cat}</b>』{jump_text}",
    parse_mode="HTML",
    reply_markup=reply_markup
)
STEP 01
貼上影音連結 (Input)
STEP 02
Gemini 摘要並送入分區
STEP 03
原處回覆跳轉按鈕 (Deep Link)
▲ 圖解架構:Telegram 知識庫自動解析與跳轉閉環工作流
傳統通知做法 vs Deep Link 直達機制體驗對比
評估維度傳統純文字通知(舊做法)Forum Deep Link 直達(新做法)
操作步驟數4 個動作(返回 ➔ 找話題 ➔ 進入 ➔ 滑動)1 個動作(點擊直達按鈕)
目標定位耗時平均約 5~8 秒即刻觸發,小於 0.3 秒
注意力保留率易被其他未讀分區紅點吸引分心100% 保持在原本的學習與吸收脈絡
多裝置相容性使用者需自行記憶分類邏輯iOS、Android、macOS、Windows 原生客戶端皆平滑跳轉
整體工具滿意度「功能可用但有點繁瑣」「行雲流水、像內建模組一樣自然」
非群組成員如果點擊了這個私有 Deep Link 會發生什麼事?

由於連結格式為 t.me/c/<clean_cid>/...,這是 Telegram 原生為私有群組設計的安全格式。非群組成員或未獲邀請的使用者點擊時,Telegram 客戶端會直接顯示「Chat not found」或「您不是此群組成員」,完全不用擔心私有知識庫內容外洩。

在 Telegram 桌面版 (macOS / Windows) 上點擊,能正常跳轉嗎?

完全支援。Telegram Desktop 與 macOS 原生版收到 t.me/c/ 協議時,會直接在應用內平滑切換左側列表至對應話題,並在聊天主畫面以藍色高亮短暫閃爍該則訊息,定位效果甚至比手機端更震撼。

想為你的社群或團隊打造流暢無阻的 Telegram AI 工作流?

真正的 AI 工具價值在於「完全不浪費使用者的時間」。歡迎找 Sam 聊聊你的自動化需求,我們用最精簡的架構幫你實現端到端的極致體驗。

與 Sam 討論 Telegram AI 代建 →

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.

  1. Multi-step navigation: Exit topic -> Scan topic list -> Tap into topic -> Scroll to bottom.
  2. Attention leakage: Notification badges in other topics distract users during navigation.
  3. Broken loop: Static text gives no direct affordance to inspect or reply to the AI summary.

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.

03 // Dual-Channel UI: Hyperlinks & Inline Keyboard Buttons

Upon completing audio transcription, chart rendering, and Gemini summarization, the bot updates the original prompt message with both inline text and an action button:

# 更新原對話狀態,附帶跳轉連結與按鈕
post_url = build_telegram_post_link(post_chat_id, post_thread_id, post_msg_id)
jump_text = f'\n👉 <a href="{post_url}">點此直接跳轉查看分析文 ↗</a>' if post_url else ""

reply_markup = {
    "inline_keyboard": [
        [{"text": f"📖 前往查看『{cat}』分析文 ↗", "url": post_url}]
    ]
} if post_url else None

tg_bot.edit_message(
    chat_id=chat_id,
    message_id=status_msg_id,
    text=f"✅ <b>影片分析完成!</b>\n📁 已整理發送至主題分區:『<b>{cat}</b>』{jump_text}",
    parse_mode="HTML",
    reply_markup=reply_markup
)
STEP 01
貼上影音連結 (Input)
STEP 02
Gemini 摘要並送入分區
STEP 03
原處回覆跳轉按鈕 (Deep Link)
▲ 圖解架構:Telegram Knowledge Ingestion & Deep Link Jump Workflow
Traditional Notice vs. Deep Link Jump Comparison
CriterionLegacy Text NoticeForum Deep Link Jump
Navigation Steps4 actions (Exit -> Search -> Enter -> Scroll)1 tap on the direct action button
Locate Latency5-8 seconds manual searchingInstant (<0.3s native view transition)
Attention RetentionEasily distracted by other unread badges100% focused on current context
Cross-Platform SupportManual cognitive burden across devicesSmooth client jump on iOS/Android/Mac/PC
Perceived UXFunctional but cumbersomeFrictionless 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.

Discuss Telegram AI Automation With Sam →
>_ 快速導航指令台 >_ QUICK COMMAND PALETTE