How to Create a Telegram Bot and Send Messages
March 26, 2025 Β· View on GitHub
This guide will walk you through creating a Telegram bot, retrieving your chat ID, and sending messages using the telegram-owl CLI tool.
Step 1: Create a Telegram Bot and Get a Token
-
Open Telegram application then search for
@BotFatheror click here -
Click Start
-
Click Menu -> /newbot or type
/newbotand hit Send -
Follow the instructions:
- Choose a name for your bot
- Choose a username (must end with
bot, e.g.SpaceCatNotificationsBot)
-
You will receive a response like:
Done! Congratulations on your new bot. You will find it at t.me/SpaceCatNotificationsBot. Use this token to access the HTTP API: 123456789:ABCdefGhIJkLmNoPQRstuVWXyz12345678 -
Copy and securely store the token. This is your bot's authentication key β do not share it publicly.

Step 2: Get Chat ID for a Private Chat (1-on-1)
-
Open a chat with your new bot in Telegram
-
Click Start and send any message (e.g. "hello")

-
In your browser, open the following URL (replace
{TOKEN}with your actual bot token):https://api.telegram.org/bot{TOKEN}/getUpdatesExample:
https://api.telegram.org/bot123456789:ABCdefGhIJkLmNoPQRstuVWXyz12345678/getUpdates -
You'll see a JSON response like this (if not, send another message to the bot and refresh the page):

-
Find the
chat idvalue insideresult[0].message.chat.id.
This is your chat ID, e.g.1122445.
β Test It!
Once you have your bot token and chat ID, you can send your first message using:
telegram-owl --token=123456789:ABCdef --chat=1122445 --message="π Hello from Telegram Owl!"
Youβre ready to go! π¦
For more advanced usage, you can find information on how to get chat id for a channel, group chat, or a topic in a group chat in the following sections:
π’ Get Chat ID for a Channel
-
Add your Telegram bot into a channel
-
Send a random message to the channel
-
Visit the same URL:
https://api.telegram.org/bot{TOKEN}/getUpdates -
Look for a JSON response like:
{ "ok": true, "result": [ { "channel_post": { "chat": { "id": -1001234567890, "title": "My Channel", "type": "channel" }, "text": "Test message" } } ] } -
The
chat.idis your channel ID. Channel IDs start with-100, e.g.-1001234567890.
π₯ Get Chat ID for a Group Chat
This method works best using the Telegram desktop app.
-
Add your bot to the group chat
-
Send a message to the group
-
Right-click on the message and select Copy Message Link
-
The link looks like this:
https://t.me/c/194xxxx987/11/13 -
The number after
/c/is your group ID:194xxxx987
To use it in the API, prefix it with-100, resulting in:-100194xxxx987
π§΅ Get Topic ID for a Group Chat (Forum Thread)
To send a message to a specific topic (thread) inside a group chat:
-
Copy a message link from the topic using Copy Message Link
-
Example link:
https://t.me/c/194xxxx987/11/13 -
The number after
/c/194xxxx987/is the topic ID:11
Use this ID with the --thread flag in telegram-owl.