Skip to content

Telegram: Getting Group IDs

jack edited this page Feb 8, 2019 · 2 revisions

Getting Group IDs

When communicating with NxBot via group you'll need to do two things. 1) Add your NxBot Telegram Bot to your group and 2) Get the group's ID to add to the appropriate NxBot configuration variables.

Screenshots in this guide are taken from the Telegram Desktop app, but the process should be the same on the mobile app.

Unfortunately there isn't a straightforward way to obtain group IDs from the Telegram app, but there is a bot that can make it really easy!

  1. Search for "@Telegram Bot Raw" (note the spaces)

    image

  2. Click "Start"

    image

    Immediately, the bot will send you detailed information. This is useful for obtaining your user ID, but we're going to get a group ID.

  3. Add the bot to your group

    Click the "..." button in the top right of the bot chat screen. Choose "Add to Group", shown below:

    image

    Choose the group we're looking to get the ID of. Click OK to confirm.

    image

  4. Locate the group ID

    After clicking OK the bot will be added to your group and after a second you should see a dump of information.

    What we're after is the group's id. It's referred to, in this dump, under "chat" and it's the "id" value. You may need to scroll up to see the value.

    image
    Group ID value underlined. For privacy reasons, I've blurred and omitted my personal values.

  5. Copy the group ID

    Telegram group IDs are, generally, negative (- prefixed) 9-digit numbers: e.g. -123456789. Copy the ID shown.

    This can be used in the TG_GROUP_WHITELIST (env) / tg_group_whitelist (yaml) configuration for NxBot. It can also be used in the TG_MOTION_RECIPIENT (env) / tg_motion_recipient (yaml) value, to receive motion-event action camera snapshots.

  6. Remove "@Telegram Bot Raw" from your group.

    Now that we have the information we were after, you'll want to remove the bot from your group. Otherwise, you'll receive endless replies with data dumps for every message. Useful for certain situations, but probably not what you want.

    To remove the bot:

    1. Click the "..." in the top right of the group chat screen
    2. Choose "Manage Group"
    3. Choose "Members"
    4. Choose "Remove" next to "Telegram Bot Raw"
    5. Confirm by clicking "Remove"

Clone this wiki locally