telegrampython-telegram-bot

How to get topic id for telegram group chat?


Recently Telegram added support for Topics in Groups in Bot API version 6.3 and this support added into python-telegram-bot version 13.15 (please find changelog https://docs.python-telegram-bot.org/en/stable/changelog.html)

It's not clear how to get a Topic ID (message_thread_id) for topics in Grpups where topics enabeled.

Any suggestion?

I'm trying to find a way how to get topic id for telegram group chats. Please be aware that I talking about message_thread_id, please do not confuse with chat_id.


Solution

  • You can try to get the message_thread_id from the message link

    1. send a message to the topic you need from the application
    2. right click on the sent message and choose "Copy message link"
    3. paste link somewhere
    4. you will see something like this: https://t.me/c/1112223334/25/33
    5. the value 25(value after long number) from the link will be message_thread_id

    I assume that -100 + 1112223334 - will be equal chat_id

    The number after will be message_thread_id

    And the last one should be message_id