-
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
-
Create new Telegram group in web or mobile application and add the new bot in your group.
-
Send dummy message into your group, replace botname_bot with actual bot name:
/my_id @botname_bot
-
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.
-
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}
Last active
February 19, 2025 06:50
-
-
Save zapisnicar/247d53f8e3980f6013a221d8c7459dc3 to your computer and use it in GitHub Desktop.
How to create Telegram bot and send messages to group
@Hadatko you have to either
- 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. - Make the bot an admin
Thank you, maybe try next time. Meantime i solved it differently
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, is this still valid? Because i am getting this even i am sending messages to my bot.
{"ok":true,"result":[]}