Telegram Bot - how to get a group chat id?

后端 未结 12 1114
北海茫月
北海茫月 2020-11-30 16:42

I\'ve been using telegram_bot, and trying to get groupChat id to send notifications to group chat, but don\'t know which methods I have to use for it.

For getting ch

12条回答
  •  一生所求
    2020-11-30 17:34

    In order to get the group chat id, do as follows:

    1. Add the Telegram BOT to the group.

    2. Get the list of updates for your BOT:

      https://api.telegram.org/bot/getUpdates
      

      Ex:

      https://api.telegram.org/bot123456789:jbd78sadvbdy63d37gda37bd8/getUpdates
      
    3. Look for the "chat" object:

    {"update_id":8393,"message":{"message_id":3,"from":{"id":7474,"first_name":"AAA"},"chat":{"id":,"title":""},"date":25497,"new_chat_participant":{"id":71,"first_name":"NAME","username":"YOUR_BOT_NAME"}}}

    This is a sample of the response when you add your BOT into a group.

    1. Use the "id" of the "chat" object to send your messages.

提交回复
热议问题