readBusinessMessage
Returns: TrueOfficial docs ↗
Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.
Parameters
business_connection_idStringRequiredUnique identifier of the business connection on behalf of which to read the message
chat_idIntegerRequiredUnique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.
message_idIntegerRequiredUnique identifier of the message to mark as read
Returns
On success, True is returned.
GramIO Usage
Mark every incoming business message as read automatically:
ts
bot.on("business_message", async (ctx) => {
await bot.api.readBusinessMessage({
business_connection_id: ctx.businessConnectionId,
chat_id: ctx.chat.id,
message_id: ctx.id,
});
});Mark a message as read only after the bot has processed and replied to it:
ts
bot.on("business_message", async (ctx) => {
// Process the message first
if (ctx.text) {
await bot.api.sendMessage({
business_connection_id: ctx.businessConnectionId,
chat_id: ctx.chat.id,
text: `Echo: ${ctx.text}`,
});
}
// Mark as read after handling
await bot.api.readBusinessMessage({
business_connection_id: ctx.businessConnectionId,
chat_id: ctx.chat.id,
message_id: ctx.id,
});
});Mark a specific message as read by ID (e.g., after a delayed workflow):
ts
async function markRead(
businessConnectionId: string,
chatId: number,
messageId: number
) {
return bot.api.readBusinessMessage({
business_connection_id: businessConnectionId,
chat_id: chatId,
message_id: messageId,
});
}Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: business connection not found | The business_connection_id is invalid or the business connection no longer exists. |
| 400 | Bad Request: chat not found | The chat_id does not correspond to an existing or accessible chat. |
| 400 | Bad Request: message not found | The message_id does not exist in the specified chat. |
| 400 | Bad Request: chat is not active | The chat has not been active in the last 24 hours. Messages in inactive chats cannot be marked as read via this method. |
| 403 | Forbidden: not enough rights | The business bot connection does not have the can_read_messages right. |
| 403 | Forbidden: bot was blocked by the user | The user has blocked the bot. |
| 429 | Too Many Requests: retry after N | Flood control triggered. Wait N seconds before retrying. |
Tips & Gotchas
can_read_messagesright is required. This is a business-specific bot right distinct from standard chat permissions. Ensure it is enabled in BotFather's business bot settings, and verify it viagetBusinessConnectionif needed.- 24-hour activity window. The chat must have been active in the last 24 hours. If the last message in the chat is older, this call will return a 400 error. There is no way to retroactively mark messages in inactive chats.
chat_idis always anIntegerhere. Unlike many other methods,readBusinessMessageaccepts only numeric chat IDs — not@usernamestrings. Usectx.chat.iddirectly from the business message context.- Order matters if you need delivery confirmations. Call
readBusinessMessageonly after you are sure your bot has fully processed the message. Marking a message as read before processing it may signal to the customer that their query was handled even if your bot subsequently fails. - Business messages arrive via the
business_messageupdate type. Make sureallowed_updatesincludes"business_message"in your webhook orgetUpdatesconfiguration, otherwise you will never receive the messages to mark as read.
See Also
- getBusinessConnection — Retrieve business connection details and check granted rights
- deleteBusinessMessages — Delete messages in a business chat
- sendMessage — Reply to a business message (pass
business_connection_id)