Ephemeral messages
Messages only one person sees, ephemeral commands and editing in place.
An ephemeral message is seen by one person only. It sits in the chat's history among ordinary messages, marked "Only you can see this" with a "Dismiss" button, like ephemeral answers in Discord. It is not kept in the history, never reaches search, notifications or unread counts, and cannot be replied to, pinned or forwarded.
It lives 24 hours from the first send, until the bot deletes it, the person dismisses it or the app closes.
When a bot can answer this way
Only in answer to a person's action, in the same chat and within 15 minutes:
- to an ephemeral command:
idof theephemeral_command; - to a button press:
idof thecallback_query.
{
"chat_id": "…",
"text": "Your balance: 1,200 ₸",
"ephemeral": { "interaction_id": "<interaction id>" }
}The answer:
{ "ok": true, "result": { "ephemeral_message_id": "…", "chat": {...}, "receiver": {...}, "expires_at": 1793136400 } }An ephemeral message passes the same checks as an ordinary one (a closed chat, blocks, the filter) and spends the same rate budget. One bot may keep up to 20 live ephemeral messages for one person: the twenty-first deletes the oldest.
Ephemeral commands
A command with "ephemeral": true in setMyCommands writes nothing to the chat: nobody else sees
the invocation, and the bot gets
{
"update_id": 31,
"ephemeral_command": {
"id": "…", "from": {...}, "chat": {...},
"text": "/balance", "command": "balance", "args": "",
"date": 1793050000
}
}The app tells the person beforehand: "Only you will see the answer".
Editing in place
Buttons of an ephemeral message are pressed too: a callback_query update with
ephemeral_message_id. The bot can answer by replacing the ephemeral message itself:
{ "chat_id": "…", "text": "Counter: 2", "ephemeral": { "interaction_id": "<press id>", "replace": true } }- A button of an ephemeral message was pressed:
replacechanges it in place (same ID, same expiry). - A button of an ordinary message was pressed:
replaceshows the ephemeral message in place of that message, for the presser only. Everyone else sees the original. replace_message_idreplaces a particular ephemeral message of this bot.
Without presses, editEphemeralMessage changes an ephemeral message and deleteEphemeralMessage
deletes it.
The server keeps ephemeral messages in memory only, and the app never stores them on the device.