# Telegram private chat topics: BOT_TOPIC_WRONG_HOME errors

> How message_thread_id works in a bot's private chat topics, what the November 2026 BOT_TOPIC_WRONG_HOME outage looked like and how to fall back safely.

Published 2026-11-24. Z-API Omni team.

`BOT_TOPIC_WRONG_HOME` and "message thread not found" hit bots using private-chat topics from about 15:03 UTC on November 9, 2026 until about 10:40 UTC on November 10. Users reported the outage in [tdlib/telegram-bot-api#944](https://github.com/tdlib/telegram-bot-api/issues/944), and it was closed as completed on November 10. Neither error string appears in the Bot API reference, and Telegram published no statement or root cause. Topics created during the outage stayed broken, per the reports. The durable fix is defensive code: copy `message_thread_id` only from topic messages, and fall back to the main chat when a topic call fails.

Topics in forum supergroups, with admin rights and the General topic, are covered in [Telegram forum topics: message_thread_id and createForumTopic](/academy/articles/telegram-bot-forum-topics-message-thread-id/). This post deals with the private chat between one user and the bot.

## How topics in a bot's private chats work

Telegram added the feature in steps ([Bot API changelog](https://core.telegram.org/bots/api-changelog), accessed 2026-11-24):

| Bot API version | Date | What it added |
| --- | --- | --- |
| 9.3 | December 31, 2025 | Topics in private chats with bots. `has_topics_enabled` in `getMe`, and `message_thread_id` and `is_topic_message` on private-chat messages |
| 9.4 | February 9, 2026 | `allows_users_to_create_topics`, and bots creating topics with `createForumTopic` |
| 10.4 | November 9, 2026 | Topic links in the format `https://t.me/<bot_username>/<message_thread_id>` |
| 10.5 | November 22, 2026 | `has_topic_sidebar`, and all three topic settings writable through `setMySettings` |

The topic link from 10.4 "opens the topic only for the user in the private chat with whom the topic exists." Other users can't open it, so it won't work as a shared link to a thread.

The [features page](https://core.telegram.org/bots/features) (accessed 2026-11-24) still says "Private-chat topics need to be enabled for the bot via @BotFather." Since 10.5 you can also send `has_topics_enabled: true` to `setMySettings`. That page states no limits on topics. The new settings call, and how to read the flags back with `getMe`, are in [Telegram Bot API 10.5: getMe, BotFullInfo and setMySettings](/academy/articles/telegram-bot-api-10-5-getme-botfullinfo-setmysettings/).

## message_thread_id in private chats and in forum supergroups

The same two fields carry topics in both places: `message_thread_id` identifies the topic, and `is_topic_message` confirms the message sits in one ([Message](https://core.telegram.org/bots/api#message), accessed 2026-11-24). Branch on `is_topic_message`, as the forum topics post explains.

On the sending side, `sendMessage` accepts `message_thread_id` "for forum supergroups and private chats of bots with forum topic mode enabled only" ([sendMessage](https://core.telegram.org/bots/api#sendmessage), accessed 2026-11-24). A private chat with topic mode off has no topics to target.

Support differs by chat type:

| | Forum supergroup | Private chat with the bot |
| --- | --- | --- |
| How topic mode is turned on | The group is a forum (`is_forum: true`) | `has_topics_enabled` for the bot |
| `createForumTopic` | Bot must be an admin with `can_manage_topics` | No admin requirement stated |
| Close and reopen a topic | `closeForumTopic` and `reopenForumTopic` | Not available: both methods are supergroup-only |
| General topic | Documented, with its own methods | Not documented |
| Who can create topics | Admins with `can_manage_topics`, and members whose `ChatPermissions` include `can_manage_topics` | The bot, and users if `allows_users_to_create_topics` is true |

The close, reopen and permission rows follow the method entries in the [Bot API reference](https://core.telegram.org/bots/api#closeforumtopic), summarized in the forum topics post linked above.

`createForumTopic` creates "a topic in a forum supergroup chat or a private chat with a user" ([createForumTopic](https://core.telegram.org/bots/api#createforumtopic), accessed 2026-11-24). Store the returned `message_thread_id` with your own record. The reference has no method that lists a chat's topics.

`direct_messages_topic_id` on `sendMessage` belongs to channel direct messages. It's a separate feature from private-chat topics, so don't swap one ID for the other.

## What broke on November 9 and 10

The issue title reads "createForumTopic fails with BOT_TOPIC_WRONG_HOME; user-created topics reject bot writes and get dissolved". It was opened at 16:19 UTC on November 9 and drew 34 comments. Every comment came from users outside the project. No Telegram or maintainer reply appears in the thread.

Users reported these symptoms:

- `createForumTopic` returned "400 Bad Request: BOT_TOPIC_WRONG_HOME".
- A topic the user created arrived as a `forum_topic_created` service message. The user's first message in it came without `message_thread_id`.
- Bot writes to that topic failed with "400 Bad Request: message thread not found", and the topic then dissolved.
- `editForumTopic` with a name returned `TOPIC_ID_INVALID`. An empty `editForumTopic` returned ok for an invalid topic.

The errors came from the cloud Bot API and from local servers on 10.3 and 10.4. Topics created before the onset kept working. Reporters put the onset between about 15:03 and 15:57 UTC on November 9. Recovery was reported as "last failure ~10:30 UTC, first success ~10:40 UTC" on November 10.

Topics created during the outage "stay dead" after the fix, one reporter wrote. Another found all their past topics titled "x". Many reporters ran AI agent gateways that use topics as conversation threads. For them, a refused topic left a new session without a thread to run in.

Users posted their own workarounds. One wrote "As a workaround we now start the session in the main chat when createForumTopic is refused." Another wrote "Using the existing topic is working as a temporary workaround for me." Neither is documented by Telegram, but both match what the reference allows.

## Handle topic errors without losing the message

Telegram hasn't said what `BOT_TOPIC_WRONG_HOME` means, so don't build logic on its meaning. Build it on the call that failed. These rules come from the reference and the workarounds above. They are our recommendation, not a Telegram procedure:

1. Read `has_topics_enabled` from `getMe` at startup, and skip topic calls if it's false.
2. Copy `message_thread_id` into a reply only when `is_topic_message` is true.
3. If a send fails with "message thread not found", send once more without `message_thread_id`.
4. If `createForumTopic` returns a 400, continue the conversation in the main chat.
5. Log the topic ID and the `description` of every failure, so you can repair records later.

This long-polling bot applies all five. It runs on Node.js 18 or later with the built-in `fetch`. Send it `/new` in a private chat to open a topic, or any text to get an echo in the same place. [`getUpdates`](https://core.telegram.org/bots/api#getupdates) fails while a webhook is set, so remove the webhook first or move the two functions into your webhook handler.

```javascript
// topics-bot.mjs
// usage: TELEGRAM_BOT_TOKEN=YOUR_TOKEN node topics-bot.mjs
const BASE = process.env.TELEGRAM_API_BASE ?? "https://api.telegram.org";
const TOKEN = process.env.TELEGRAM_BOT_TOKEN;
if (!TOKEN) throw new Error("TELEGRAM_BOT_TOKEN is not set");
const API = `${BASE}/bot${TOKEN}/`;

class TelegramError extends Error {
  constructor(method, body) {
    super(`${method} failed: ${body.error_code} ${body.description}`);
    this.code = body.error_code;
    this.description = body.description ?? "";
    this.retryAfter = body.parameters?.retry_after;
  }
}

async function call(method, params = {}, timeoutMs = 10_000) {
  const res = await fetch(API + method, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(params),
    signal: AbortSignal.timeout(timeoutMs),
  });
  const body = await res.json();
  if (!body.ok) throw new TelegramError(method, body);
  return body.result;
}

const isThreadNotFound = (err) =>
  err instanceof TelegramError &&
  err.code === 400 &&
  /message thread not found/i.test(err.description);

// Send to the message's topic. If Telegram says the topic is gone, send once to the main chat.
async function reply(message, text) {
  const base = { chat_id: message.chat.id, text };
  if (message.is_topic_message && message.message_thread_id) {
    try {
      return await call("sendMessage", { ...base, message_thread_id: message.message_thread_id });
    } catch (err) {
      if (!isThreadNotFound(err)) throw err;
      console.warn("topic unavailable, using main chat", message.chat.id, message.message_thread_id);
    }
  }
  return call("sendMessage", base);
}

// Open a topic in a private chat. Return null on a 400 so the caller falls back to reply().
async function openTopic(chatId, name) {
  try {
    const topic = await call("createForumTopic", { chat_id: chatId, name });
    return topic.message_thread_id;
  } catch (err) {
    if (err instanceof TelegramError && err.code === 400) {
      console.warn("createForumTopic refused:", err.description);
      return null;
    }
    throw err;
  }
}

const me = await call("getMe");
console.log(`@${me.username} has_topics_enabled=${me.has_topics_enabled}`);

let offset = 0;
for (;;) {
  let updates;
  try {
    updates = await call("getUpdates", { offset, timeout: 30, allowed_updates: ["message"] }, 40_000);
  } catch (err) {
    const wait = err instanceof TelegramError && err.retryAfter ? err.retryAfter : 5;
    console.error(err.message, `(retrying in ${wait}s)`);
    await new Promise((resolve) => setTimeout(resolve, wait * 1000));
    continue;
  }

  for (const update of updates) {
    offset = update.update_id + 1;
    const message = update.message;
    if (!message?.text || message.chat.type !== "private") continue;

    try {
      if (message.text.startsWith("/new") && me.has_topics_enabled) {
        const threadId = await openTopic(message.chat.id, "New request");
        if (threadId) {
          await call("sendMessage", {
            chat_id: message.chat.id,
            message_thread_id: threadId,
            text: "Topic opened. Write here.",
          });
          console.log("topic", message.chat.id, threadId);
        } else {
          await reply(message, "Topics are unavailable right now. Let's continue here.");
        }
      } else {
        await reply(message, `You wrote: ${message.text}`);
      }
    } catch (err) {
      console.error("update", update.update_id, err.message);
    }
  }
}
```

The `/new` branch sends its first message with `call` instead of `reply`, because the new topic has no incoming message to copy from. Replace the `console` calls with your own logger and store each `threadId` next to the conversation it belongs to.

If you route by topic in your own database, also check topics you created during an incident. The reports say those topics didn't recover, so mark them closed on your side and open a fresh one on the next message.

## If getMe returns 429 retry after 32

A second incident began late on November 23. Users in [tdlib/telegram-bot-api#1103](https://github.com/tdlib/telegram-bot-api/issues/1103) got this from `getMe`:

```json
{"ok":false,"error_code":429,"description":"Too Many Requests: retry after 32","parameters":{"retry_after":32}}
```

Per the reports, valid tokens hung about 33 to 34 seconds before that answer. Invalid tokens got 401 at once, and bots already running kept working. Waiting for `retry_after` plus 5 seconds didn't help, and neither did revoking the token. Users reported recovery between about 08:32 and 08:35 UTC on November 24. Issue #1103 was still open on 2026-11-24, with no Telegram reply.

A related report, [#1110](https://github.com/tdlib/telegram-bot-api/issues/1110), showed `retry_after` values of 1, 6 and 32. It also showed python-telegram-bot 22.8 failing in `Application.initialize()`. Its last comment, from a user, reads "revoking the tokens had removed the webhooks, so I just had to set them again with setWebhook." Telegram's reference doesn't document that effect. If you revoked a token during the incident, run `getWebhookInfo` with the new token and set the webhook again if the URL is empty.

The loop above honors `retry_after`, but that won't fix a server-side fault. The startup `getMe` call isn't retried, so during an incident like this one the script exits; start it again after recovery. General 429 handling is in [Telegram Bot API limits: 429 errors and retry_after](/academy/articles/telegram-bot-api-rate-limits-flood-429/).

*Z-API Omni team*
