Instructions for creating a new Telegram Bot and getting chat_id from a particular group or chat.
-
Go to @BotFather on Telegram.
-
Send
/newbot
, to start creating a new Bot. -
Set the bot's username and username.
-
Now you need to allow your Bot to send direct messages, so send
/setjoingroups
to @BotFather, select your Bot and click Enable: -
Get the Bot token and add it to your .env file.
Bot Token in .env:
-
If you want to send messages to a group:
- Add your Bot to a Telegram group.
- Send any message from another user to this group.
-
If you want send direct messages to a user:
- Search for your bot name, and select the chat.
- Send
/start
to your Bot.
-
Visit the following link to get updates about your bot and get chat_id:
https://api.telegram.org/botXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/getUpdates
Replace all X in the URL with your Bot Token.
Hope this helps you!