send_chat_action()

Client.send_chat_action()

Tell the other party that something is happening on your side.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use “me” or “self”. For a contact that exists in your Telegram address book you can use his phone number (str). You can also use chat public link in form of t.me/<username> (str).

  • action (ChatAction) – Type of action to broadcast.

  • message_thread_id (`int`) – Unique identifier for the target message thread (topic) of the forum. for forum supergroups only.

  • business_connection_id (str, optional) – Business connection identifier. for business bots only.

  • emoji (str, optional) – The animated emoji. Only supported for TRIGGER_EMOJI_ANIMATION and WATCH_EMOJI_ANIMATION.

  • emoji_message_id (int, optional) – Message identifier of the message containing the animated emoji. Only supported for TRIGGER_EMOJI_ANIMATION.

  • emoji_message_interaction (raw.types.DataJSON, optional) – Only supported for TRIGGER_EMOJI_ANIMATION.

Returns:

bool – On success, True is returned.

Raises:

ValueError – In case the provided string is not a valid chat action.

Example

from pyrogram import enums

# Send "typing" chat action
await app.send_chat_action(chat_id, enums.ChatAction.TYPING)

# Send "upload_video" chat action
await app.send_chat_action(chat_id, enums.ChatAction.UPLOAD_VIDEO)

# Send "playing" chat action
await app.send_chat_action(chat_id, enums.ChatAction.PLAYING)

# Cancel any current chat action
await app.send_chat_action(chat_id, enums.ChatAction.CANCEL)