telegramtelegram-bot

Telegram Bot API: TelegramError: 400: Bad Request: message to be replied not found when replying to a message in another chat


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:

https://api.telegram.org/bot<TOKEN>/sendMessage
{
  "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
  }
}
{
    "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:

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!

NOTE: Both User1 and User2 have started the bot before

  1. User1 sent a message (which was a reply to the message that I mentioned earlier) to the bot using "Reply in Another Chat" feature

  2. The bot used the forwardMessage and copyMessage methods to send it to User2, and both WORKED!


My Questions:

  1. Why is this error occurring even though the message_id and chat_id are correct?

  2. Is there an additional setup or restriction I might've missed?

  3. Could this be an issue with the Telegram Bot API itself?


Solution

  • 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:

    NOTE: Privacy mode is enabled by default for all bots, except bots that were added to a group as admins. Read more

    3. Channels: Only where the bot is an admin.