I’m working with the Telegram Bot API and trying to reply to a message from another chat by specifying the message_id
and chat_id
in the reply_parameters
parameter in the sendMessage method. Despite verifying that both message_id
and chat_id
are correct and valid, I keep encountering this error:
TelegramError: 400: Bad Request: message to be replied not found
What I Tried:
1. Verified the message_id
and chat_id
and both are correct.
2. Tested via Postman:
- Endpoint:
https://api.telegram.org/bot<TOKEN>/sendMessage
- Payload:
{
"chat_id": 0, // Replace it with a real chat_id
"text": "This is a reply to a message from another chat",
"reply_parameters": {
"message_id": 361,
"chat_id": -1001005640892
}
}
- Response:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message to be replied not found"
}
3. Checked Bot Permissions:
The bot has sufficient permissions in both chats:
- The user has started the bot before, so it has permission to send messages to them.
- The specified
chat_id
in thereply_parameters
belongs to the Telegram’s official channel and it’s a public channel.
4. Checked Cross-Chat Restrictions:
This is not a business account, so cross-chat replies should be supported.
5. Tested both forwardMessage and copyMessage methods to send a message sent to the bot by a user (which was a reply to a message in another chat that I tried to specify in the reply_parameters
before), without passing reply_parameters
, and it worked!
- How:
NOTE: Both User1 and User2 have started the bot before
-
User1 sent a message (which was a reply to the message that I mentioned earlier) to the bot using "Reply in Another Chat" feature
-
The bot used the
forwardMessage
andcopyMessage
methods to send it to User2, and both WORKED!
My Questions:
-
Why is this error occurring even though the
message_id
andchat_id
are correct? -
Is there an additional setup or restriction I might’ve missed?
-
Could this be an issue with the Telegram Bot API itself?
2
Answers
The error occurred because my bot wasn't an admin in the channel specified in the
reply_parameters
. According to the Telegram Bots Documentation, all bots, regardless of settings, can only access messages from:1. Private chats: Only when a user initiates the chat by starting it.
2. Groups / Supergroups:
Privacy Mode =
Enabled
:Privacy Mode =
Disabled
:3. Channels: Only where the bot is an admin.
By default, bots can only access messages in chats with the bot (the bot is member of), so what happened here that the bot is not member of the
chat_id
inreply_parameters
.