Skip to content

The agent that grows with you

fix(telegram): point dm_topics prerequisite text at BotFather Threaded Mode

chelsealong0c872b611c5c
diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py
index ced45f4b52f..f367ea7eb65 100644
--- a/plugins/platforms/telegram/adapter.py
+++ b/plugins/platforms/telegram/adapter.py
@@ -2478,9 +2478,11 @@ class TelegramAdapter(BasePlatformAdapter):
"[%s] DM topic '%s' already exists in chat %s (will be mapped from incoming messages)", self.name, name, chat_id)
elif "not a forum" in error_text or "forums_disabled" in error_text:
logger.warning(
- "[%s] Cannot create DM topic '%s' in chat %s: Topics mode is not enabled. "
- "The user must open the DM with this bot in Telegram, tap the bot name "
- "at the top, and enable 'Topics' in chat settings before topics can be created.",
+ "[%s] Cannot create DM topic '%s' in chat %s: Threaded Mode is not enabled. "
+ "The bot owner must open the BotFather Mini App (search 'botfather' in "
+ "Telegram, tap Open on the search result) -> My bots -> this bot -> Bot "
+ "Settings -> Threads Settings -> enable Threaded Mode. This cannot be enabled "
+ "from the DM chat, nor from the BotFather /mybots text menu.",
self.name, name, chat_id)
else:
logger.warning(
diff --git a/tests/gateway/test_dm_topics.py b/tests/gateway/test_dm_topics.py
index d1cc996101a..9bf90c39867 100644
--- a/tests/gateway/test_dm_topics.py
+++ b/tests/gateway/test_dm_topics.py
@@ -141,6 +141,30 @@ async def test_create_dm_topic_handles_generic_error():
assert result is None
+async def test_create_dm_topic_not_a_forum_points_to_botfather_threaded_mode(caplog):
+ """The 'not a forum' warning must send the operator to the real toggle.
+
+ A bot DM has no "Topics" toggle to tap in chat info — that UI only
+ exists for group forums. The only place that enables Private Chat
+ Topics for a bot DM is BotFather's Threaded Mode, reachable through the
+ BotFather Mini App (not the /mybots text menu). See issue #115019.
+ """
+ adapter = _make_adapter()
+ adapter._bot = AsyncMock()
+ adapter._bot.create_forum_topic.side_effect = Exception("Bad Request: the chat is not a forum")
+
+ with caplog.at_level("WARNING"):
+ result = await adapter._create_dm_topic(chat_id=111, name="General")
+
+ assert result is None
+ warning_text = " ".join(r.message for r in caplog.records)
+ assert "BotFather" in warning_text
+ assert "Threaded Mode" in warning_text
+ assert "tap the bot name" not in warning_text
+ assert "enable 'Topics' in chat settings" not in warning_text
+
+
@pytest.mark.asyncio
async def test_ensure_dm_topic_creates_on_demand_and_persists():
"""Named delivery targets should create missing private DM topics on demand."""
diff --git a/website/docs/user-guide/messaging/telegram.md b/website/docs/user-guide/messaging/telegram.md
index d6b838a1795..29ba3a41836 100644
--- a/website/docs/user-guide/messaging/telegram.md
+++ b/website/docs/user-guide/messaging/telegram.md
@@ -716,13 +716,13 @@ Each topic gets its own conversation session, history, and context — completel
### Configuration
:::caution Prerequisites
-Before adding topics to your config, the user must **enable Topics mode** in the DM chat with the bot:
+Before adding topics to your config, the bot owner must **enable Threaded Mode** for the bot in **@BotFather**:
-1. Open your private chat with the Hermes bot in Telegram
-2. Tap the bot's name at the top to open chat info
-3. Enable **Topics** (the toggle to turn the chat into a forum)
+1. Open the BotFather **Mini App** (search `botfather` in Telegram, then tap **Open** on the search result — the classic `/mybots` text menu does not expose this setting)
+2. Go to **My bots → your bot → Bot Settings → Threads Settings**
+3. Turn on **Threaded Mode**
-Without this, Hermes will log `The chat is not a forum` on startup and skip topic creation. This is a Telegram client-side setting — the bot cannot enable it programmatically.
+There is no "Topics" toggle in the DM chat itself — a bot DM is not a group, so the group-forum toggle described in some older guides does not apply here. Without Threaded Mode, Hermes will log `The chat is not a forum` on startup and skip topic creation. See [Prerequisites](#prerequisites) below for the same steps with more detail.
:::
Add topics under `platforms.telegram.extra.dm_topics` in `~/.hermes/config.yaml`: