Fix sending messages from Bot in Telegram Group Topics

1 min read

Telegram added "Group Topics" feature to the API. It works magically as channel comments feature: all messages as comments (or in the topic) will be added to the group as a reply to system message such a post from a channel or "Topic created" message.

This way Telegram is able to gather messages and change its view as a new feature, type or screen.


I have a bot made for the Aurora Hunters community which helps to watch the solar activity. Before the update it was used in a big group chat as usual, but after conversion the group to a bunch of topics we have no ability to post messages to the main chat.

You should choose a topic to send a message

And if bot send a message just in a chat as always, you will get an error:

Error: ETELEGRAM: 400 Bad Request: failed to send message #1 with the error message "TOPIC_DELETED"

You have to add a message_thread_id param to message options to send in correctly in the topic.

const options = {}; if (msg.is_topic_message) { options.message_thread_id = msg.message_thread_id; } bot.sendChatAction(chatId, 'upload_photo'); bot.sendMediaGroup(chatId, mediaGroup, options);