These days, I am trying to make different features using ChatGPT.
When I do some work or run automation, I use a Telegram bot to send push messages.
But I often do this only once and forget about it. So, I searched the internet to do it again.
Since I have to do this anyway, I think it is better to organize everything and check my blog later. That’s why I am writing this here.
Quick Guide
To use a Telegram bot, you need bot_token and chat_id.
- bot_token → Create a Telegram bot and set a unique bot name. BotFather will give you the token.
- chat_id → Use the bot_token and request:
https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
This will return your chat_id.
1. Install Telegram (Windows, Mobile)
Since it's more convenient, I'll proceed with Windows.
Step 1: Download Telegram for Windows
- Go to the official Telegram website: https://telegram.org/apps
- Click the "Apps" menu at the top.
- Select "Telegram for Windows/Mac/Linux" (Desktop App).
Step 2: Install Telegram
- You will see "Get Telegram for Windows x64".
- Download and install it.
Now, Telegram is ready to use! 🚀
2. Create a Telegram Bot Using BotFather
Step 1: Search for BotFather
- Open Telegram.
- Use the search bar at the top and search for BotFather.
- Click on BotFather (the official bot that manages other bots).
Step 2: Create a New Bot
- Open a chat with BotFather.
- Type /newbot and send it.
- BotFather will ask you to choose a name for your bot.
- Enter a name (it must end with "_bot").
Step 3: Get Your Bot Token
- After setting the bot name, BotFather will give you a bot token.
- Example token : "7575200005:AAH00tVR5flEWrovV4-BKzzzzzzzzzz4Zo0o
- This bot token is important! Save it.
Step 4: Send a Message to Your Bot
- Open your bot’s chat by clicking the link t.me/your_bot_name.
- Press "Start".
- Type "hi" and send it.
Step 5: Get Your Chat ID
- Open your browser and enter this URL: https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
(Replace <BOT_TOKEN> with your actual bot token.) - If the request is successful, you will see a response like this:
{ "ok": true, "result": [ { "update_id": 12345678, "message": { "chat": { "id": 1990000000 }, "text": "hi" } } ] }
- The "chat": {"id": 1990000000} part contains your chat_id.