reopenForumTopic
Returns: TrueOfficial docs ↗
Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
Parameters
chat_idIntegerStringRequiredUnique identifier for the target chat or username of the target supergroup (in the format
@supergroupusername)message_thread_idIntegerRequiredUnique identifier for the target message thread of the forum topic
Returns
On success, True is returned.
GramIO Usage
ts
// Context shorthand — reopens the topic the current message belongs to
// (chat_id and message_thread_id are injected automatically from the context)
bot.on("forum_topic_closed", async (ctx) => {
await ctx.reopenTopic();
});ts
// Direct API call with explicit chat_id and message_thread_id
await bot.api.reopenForumTopic({
chat_id: -1001234567890,
message_thread_id: 42,
});ts
// Reopen a specific topic from a command with the thread ID as argument
bot.command("reopentopic", async (ctx) => {
const threadId = Number(ctx.args);
if (!threadId || isNaN(threadId)) return ctx.reply("Usage: /reopentopic <thread_id>");
await bot.api.reopenForumTopic({
chat_id: ctx.chat.id,
message_thread_id: threadId,
});
await ctx.reply(`Topic ${threadId} has been reopened.`);
});ts
// Automatically reopen topics that were closed by a specific condition
bot.on("message", async (ctx) => {
if (ctx.forumTopicClosed && ctx.chat.is_forum) {
// ctx.messageThreadId holds the thread ID of the current message
await ctx.reopenTopic();
}
});Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: chat not found | chat_id is invalid or the bot is not a member of the chat |
| 400 | Bad Request: message thread not found | message_thread_id doesn't exist in the target chat |
| 400 | Bad Request: TOPIC_NOT_MODIFIED | The topic is already open — no state change needed |
| 400 | Bad Request: method is available only for supergroups | The target chat is not a supergroup with forum mode enabled |
| 403 | Forbidden: not enough rights | Bot lacks can_manage_topics admin right and is not the topic creator |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after and use the auto-retry plugin |
Tips & Gotchas
- Forum mode must be enabled. This method only works in supergroups where the "Topics" (forum) feature is turned on. Calling it in a regular group returns an error.
can_manage_topicsis required unless the bot created the topic itself. UsepromoteChatMemberto grant this right if needed.- Context shorthand
ctx.reopenTopic()automatically fillschat_idandmessage_thread_idfrom the current message context, which is the cleanest way to reopen the topic a message was sent in. - Check topic state before calling. Calling
reopenForumTopicon an already-open topic returnsTOPIC_NOT_MODIFIED. Use this call only when you know the topic is closed. - Does not automatically unhide. Unlike
reopenGeneralForumTopic, this method does not unhide the topic — useeditForumTopicif the topic also needs to be made visible.
See Also
closeForumTopic— close an open forum topiccreateForumTopic— create a new forum topiceditForumTopic— edit a forum topic's name and icondeleteForumTopic— delete a forum topic and all its messagesreopenGeneralForumTopic— reopen the General topic specifically