send_ephemeral_message()

async Client.send_ephemeral_message()

Send an ephemeral message visible only to a specific user and the bot in a group.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

  • receiver_id (int | str) – Unique identifier (int) or username (str) of the user who will receive the ephemeral message.

  • text (str) – Text of the message to be sent. If rich_text is provided, this is ignored.

  • parse_mode (ParseMode, optional) – By default, texts are parsed using both Markdown and HTML styles. You can combine both syntaxes.

  • entities (List of MessageEntity, optional) – List of special entities that appear in message text, which can be specified instead of parse_mode.

  • reply_parameters (ReplyParameters, optional) – Description of the reply-to message.

  • reply_markup (InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply, optional) – Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

  • query_id (int, optional) – Identifier of the guest query to respond to, if this message is a reply to a guest bot query.

  • rich_text (str | InputRichMessage, optional) – Rich text (Markdown or HTML) to render a styled message. Overrides text.

  • rich_text_parse_mode (ParseMode, optional) – Parse mode for rich_text. Defaults to Markdown. Ignored when rich_text is an InputRichMessage.

  • rich_text_media (List of InputRichMessageMedia, optional) – Media rich_text refers to through tg://photo?id=, tg://video?id= or tg://audio?id= links. Ignored when rich_text is an InputRichMessage.

  • disable_web_page_preview (bool, optional) – Ignored. The ephemeral message RPC has no link preview field, so this cannot be honoured. Kept only for backwards compatibility.

Returns:

Message – On success, the sent ephemeral message is returned.

Example

# Send an ephemeral message to a specific user
await app.send_ephemeral_message(chat_id, user_id, "Hello!")