If you’re trying to get your Telegram Bot Chat ID but keep seeing this response:
{"ok":true,"result":[]}
this usually means Telegram hasn’t registered any message interaction with your bot yet.
In this guide, you’ll see why Telegram returns an empty result, how to fix it, and the exact API call that reveals your chat ID once the issue is resolved.
Prerequisites
Before we dive into the solution, make sure you’ve taken care of these prerequisites:
- Created a Telegram Bot
You need a Telegram bot to interact with. If you haven’t created one yet, here’s how:- Start a chat with BotFather.
- Create your bot by following the steps provided by BotFather.
- Once created, you’ll get a token. Keep it handy—you’re going to need it.
- Added the Bot to Your Telegram Group (Optional)
If you’re trying to get the chat ID of a group, add your bot to that group and give it permissions to send messages. - Basic Knowledge of HTTP Requests
This is optional, but it’ll be useful if you want to send API requests to Telegram and get data back. Don’t worry if you’re not an expert—I’ll guide you through it.
Why We Were Seeing { "ok": true, "result": [] }
If you’re like me, the first time you tried to fetch data using the Telegram Bot API, you probably tried this:
https://api.telegram.org/bot<Your-Bot-Token>/getUpdates
But instead of the useful chat ID or a list of updates, you saw this:
{"ok":true,"result":[]}
This empty result simply means that your bot doesn’t have any messages waiting for it to respond to or, more likely, you’re not getting the right chat ID. Telegram’s API doesn’t just give you the chat ID by default—it requires you to have some interaction with the bot first.
So, How Did I Solve This?
I was stuck with the same error for a while, but eventually, the solution clicked. Here’s what I did:
1. Start a Conversation with Your Bot
This step is crucial! Without a message interaction, Telegram doesn’t know where to send the message. So, I sent a simple “Hi” to my bot. You can do this by simply opening the bot in Telegram and typing anything.
2. Use the getUpdates API Again
Once you’ve sent a message to the bot, go back and use the getUpdates API endpoint once more. You should now see a response with your chat ID!
Example URL to call:
https://api.telegram.org/bot<Your-Bot-Token>/getUpdates
The response will now look something like this:
{
"ok": true,
"result": [
{
"update_id": 123456789,
"message": {
"message_id": 1,
"from": {
"id": 987654321,
"first_name": "Your Name",
"last_name": "Your Last Name",
"username": "YourUsername",
"language_code": "en"
},
"chat": {
"id": 123456789, // <-- This is the chat ID!
"first_name": "Your Name",
"last_name": "Your Last Name",
"username": "YourUsername",
"type": "private"
},
"date": 1624048700,
"text": "Hi"
}
}
]
}
The key part here is the "chat": { "id": 123456789 }. That’s your chat ID!
3. Use the Chat ID in Your Bot
Now that you have the chat ID, you can send messages to your bot via the API:
https://api.telegram.org/bot<Your-Bot-Token>/sendMessage?chat_id=123456789&text=Your%20message%20here
If getUpdates Still Returns an Empty Result
If you’re still not seeing your chat ID, make sure:
- You haven’t sent a message after creating the bot
- You’re checking updates from the wrong bot token
- Bot privacy mode is enabled (group chats)
- Updates were already consumed by another request
Final Thoughts
This process isn’t mentioned explicitly in the official Telegram documentation, which is why many of us end up feeling stuck. But by simply starting a conversation with your bot, we were able to get our chat ID and move forward with sending messages programmatically.
If you’re still encountering issues or need further assistance, feel free to leave a comment below. I hope this solution saves you the hours I spent trying to figure it out. Enjoy building your Telegram bot!