Skip to content

Instantly share code, notes, and snippets.

@zapisnicar
Last active June 14, 2026 01:56
Show Gist options
  • Select an option

  • Save zapisnicar/247d53f8e3980f6013a221d8c7459dc3 to your computer and use it in GitHub Desktop.

Select an option

Save zapisnicar/247d53f8e3980f6013a221d8c7459dc3 to your computer and use it in GitHub Desktop.
How to create Telegram bot and send messages to group

How to create Telegram Bot and send messages to your group

  1. Create Telegram bot:

    Search for user @BotFather in Telegram app. Type /help in BotFather chat and wait for the reply. Type in the chat:

    /newbot

    or select /newbot command from Help text. Answer few setup questions:

    • Name of your bot? Write anything you like, that info will be shown in contact details. For example:

    Dead Parrot

    • Username for your bot? Must have _bot at the end, use only Latin characters, numbers or underscore sign, for example:

    deadparrot_bot

    BotFather will give you HTTP API token, remember it and keep SECRET! Example:

    1234567890:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

  2. Create new Telegram group in web or mobile application and add the new bot in your group.

    https://web.telegram.org/

  3. Send dummy message into your group, replace botname_bot with actual bot name:

    /my_id @botname_bot

  4. Find Chat ID of your group: Type this URL in the browser - change {HTTP_API_TOKEN} to actual value

    https://api.telegram.org/bot{HTTP_API_TOKEN}/getUpdates

    From JSON result, get "chat_id" of last message in your group, including minus sign in front of it, that's Group Chat ID.

    If JSON is empty, repeat steps 3 and 4.

  5. That's it, now use the bot. For all available methods, read doc from:

    https://telegram-bot-sdk.readme.io/reference

    Example for Send Text Message method:

    https://api.telegram.org/bot{HTTP_API_TOKEN}/sendMessage?chat_id={CHAT_ID}&text={MESSAGE_TEXT}

@fedeValtira

Copy link
Copy Markdown

this is wrong:
/my_id @botname_bot

Unrecognized command. Say what?

@fedeValtira

Copy link
Copy Markdown

wrong:From JSON result, get "chat_id" of last message in your group, including minus sign in front of it, that's Group Chat ID.

JSON does't have "chat_id"

@fay000fay

Copy link
Copy Markdown

me too, it says"{"ok":true,"result":[]}"。and /my_id@****_bot command didn't work.

@ermolalex

ermolalex commented Aug 22, 2023

Copy link
Copy Markdown

It works for me fine.
"If JSON is empty, repeat steps 3 and 4."

@maidxn

maidxn commented Aug 29, 2023

Copy link
Copy Markdown

A big note is: You have to add your bot to the group chat, and everything will work fine, at least for me

@vinnAnony

Copy link
Copy Markdown

me too, it says"{"ok":true,"result":[]}"。and /my_id@****_bot command didn't work.

Ensure your bot's Group Privacy is off (to enable access to group messages).
Use BotFather to set turn off Group Privacy for your bot.
Once you do that you'll be able to see the messages.

@khaintt

khaintt commented Nov 12, 2023

Copy link
Copy Markdown

It works for me. Must add bot to group first before send command /my_id @botname_bot and then you will got the result from http request

@jooonathann

Copy link
Copy Markdown

Thank you! It works great

@Maadtin

Maadtin commented Jan 15, 2024

Copy link
Copy Markdown

This is sending the messages to the group as if they were from the admin and not from the bot, any help?

@bukkake151

Copy link
Copy Markdown

In the group, go to admins, click on the bot and untick 'remain anonymous' . Depends on the settings, you might have to use the owner account and not a admin account

@mjova

mjova commented Sep 3, 2024

Copy link
Copy Markdown

me too, it says"{"ok":true,"result":[]}"。and /my_id@****_bot command didn't work.

You have to change {HTTP_API_TOKEN} with token. The curly braces {} should not be in the link...

@Hadatko

Hadatko commented Jan 1, 2025

Copy link
Copy Markdown

Hello, is this still valid? Because i am getting this even i am sending messages to my bot.
{"ok":true,"result":[]}

@tgdn

tgdn commented Jan 29, 2025

Copy link
Copy Markdown

@Hadatko you have to either

  1. Disable group privacy (open BotFather and type /setprivacy, pick you bot and disable). You need to remove and re-add the bot to your group.
  2. Make the bot an admin

@Hadatko

Hadatko commented Feb 1, 2025

Copy link
Copy Markdown

Thank you, maybe try next time. Meantime i solved it differently

@jrosell

jrosell commented Mar 14, 2026

Copy link
Copy Markdown

Thank you, maybe try next time. Meantime i solved it differently

how?

@Hadatko

Hadatko commented Mar 16, 2026

Copy link
Copy Markdown

Sorry, it was long time ago. I was trying more solutions so i wasn't sure which one worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment