send_chat_action()#
- Client.send_chat_action()#
Use this method when you need to tell the user that something is happening on the bot’s side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
Usable by ✅ Users ✅ BotsWe only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
- 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).action (
ChatAction
) – Type of action to broadcast.progress (
int
, optional) – Upload progress, as a percentage.message_thread_id (
int
, optional) – Unique identifier for the target message thread; for supergroups onlybusiness_connection_id (
str
, optional) – Unique identifier of the business connection on behalf of which the action will be sentemoji (
str
, optional) – The animated emoji. Only supported forTRIGGER_EMOJI_ANIMATION
andWATCH_EMOJI_ANIMATION
.emoji_message_id (
int
, optional) – Message identifier of the message containing the animated emoji. Only supported forTRIGGER_EMOJI_ANIMATION
.emoji_message_interaction (
raw.types.DataJSON
, optional) – Only supported forTRIGGER_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)