Mark Telegram Messages Read: Choose a Safe Message Cutoff
To mark Telegram messages read through UnifyPort, send the conversation ID and one received message ID as up_to_message_id. The action marks messages up to and including that cutoff; it is not a request to mark only that individual message. Capture the cutoff from the messages the operator actually reviewed, rather than looking up the newest message when a background job runs.
A read cutoff is a range, not a receipt list
Telegram’s official messages.readHistory documents max_id as an inclusive upper boundary when positive. UnifyPort exposes its own Mark conversation as read contract, with different request field names and explicit Telegram validation.
Key decisions:
- Select one inbound message from the same account and conversation.
- Keep its ID as a string; do not substitute the webhook event ID.
- Do not send a comma-separated list,
0, or an omitted cutoff. - Do not attach the WhatsApp sender-ID or playback parameters to this Telegram request.
- Keep ticket assignment and resolution in your application, separate from provider read state.
This article concerns an authorized Telegram user account, not a BotFather-token integration. If that identity choice is unclear, start with the Telegram credential comparison.
Freeze what the operator reviewed
Consider a hypothetical inbox: an operator reviews an inbound message, then another customer message arrives before the read request runs. If the worker replaces the captured cutoff with the latest stored message ID, it can mark work read that the operator never saw.
Recommended application design:
- Authenticate and persist inbound events before exposing them in the inbox.
- When the operator deliberately marks reviewed content read, capture the workspace, account, conversation, and selected inbound message together.
- Verify server-side that the operator may access that account and that the selected message belongs to this conversation.
- Save the selected cutoff with the local action. A later arrival must not change it.
- Build the API request from that saved selection, not from a fresh “latest message” query.
These are application safeguards, not extra UnifyPort fields. If the UI shows only part of a conversation, make the action’s range explicit: mark through this message also covers earlier messages, including ones not currently visible. Do not present it as a single-message toggle.
Build the Telegram request
The documented route is POST /v1/accounts/{account_id}/conversations/read. Keep X-Api-Key on the backend. Take conversation_id from data.conversation.id and the cutoff from data.message.id on a stored message.received event whose data.message.direction is inbound.
This illustrative JavaScript helper only constructs the body. It does not verify webhook signatures, authorize an operator, perform a network request, or prove the selected message was reviewed:
function telegramReadBody(event, accountId, conversationId) {
if (event?.type !== 'message.received' ||
event.provider !== 'telegram' ||
event.account_id !== accountId ||
event.data?.conversation?.id !== conversationId ||
event.data?.message?.direction !== 'inbound') {
throw new Error('Select an inbound message in this account and chat');
}
const rawId = event.data.message.id;
if (typeof rawId !== 'string') throw new Error('Expected a string ID');
const id = rawId.trim();
if (!/^[0-9]+$/.test(id)) throw new Error('Expected ASCII decimal digits');
const value = BigInt(id);
if (value < 1n || value > 2147483647n) {
throw new Error('Message ID is outside the documented range');
}
return { conversation_id: conversationId, up_to_message_id: id };
}
The reference allows surrounding whitespace to be trimmed but rejects internal whitespace, signs, decimals, exponents, and non-ASCII digits. The wire field remains a string. For Telegram, a non-empty up_to_message_sender_id is invalid; receipt_type=played is not a Telegram read action. Omit both here.
Record the outcome without widening the action
A successful data.ok=true confirms request processing. It does not establish that a human read every earlier message or that the support ticket is resolved. Store the local action and API outcome separately.
On failure, retain HTTP status, error.code, and request_id where available. A validation error needs corrected input, not an unchanged retry loop. A timeout leaves the result uncertain: retain the original target for investigation instead of rebuilding a request around a newer message.
Receiving a message.read event is a different workflow. The batch receipt guide processes explicitly identified receipt messages; do not interpret its data.message.ids array as the input for this cutoff action.
UnifyPort is an unofficial interface. Its normalized endpoint does not make every provider’s read behavior identical, and this workflow does not establish Telegram unread-action support or media-playback support.
Checks and FAQ
Suggested checks—not reported test results—include a new message arriving after selection, an account switch, an outbound message selected accidentally, an event ID substituted for a message ID, 0, a comma-separated list, and a timeout. Confirm none silently advances the cutoff.
Can I omit the ID to mark the whole Telegram chat read?
No. This contract requires one received message ID. Omitting it or using 0 is not supported.
Does the action mark only the selected message?
No. The selected message is the inclusive upper boundary. Label the UI accordingly.
Can webhook intake automatically mark messages read?
Do not make that the default policy. Durable intake proves your system received the event, not that someone reviewed the conversation.
Next step and sources
Implement one explicit “mark through this message” control against the read-action reference. Test selection and account boundaries before enabling background execution.
Sources checked on 2026-11-25:
Turn messaging integration into a stable product pipeline.
Start by sending through one API, then bring every inbound message back into your business system with standard events.