Message

class aiogram.types.message.Message(conf: Optional[Dict[str, Any]] = None, **kwargs: Any)[source]

Bases: TelegramObject

This object represents a message.

https://core.telegram.org/bots/api#message

Deserialize object

Parameters
  • conf

  • kwargs

is_forward() bool[source]

Check that the message is forwarded. Only forward_date is required to be in forwarded message.

Returns

bool

is_command() bool[source]

Check message text is command

Returns

bool

get_full_command() Optional[Tuple[str, str]][source]

Split command and args

Returns

tuple of (command, args)

get_command(pure=False) Optional[str][source]

Get command from message

Returns

get_args() Optional[str][source]

Get arguments

Returns

parse_entities(as_html=True) str[source]

Text or caption formatted as HTML or Markdown.

Returns

str

property from_id: int

User id if sent by user or chat/channel id if sent on behalf of a channel or chat

Returns

int

property md_text: str

Text or caption formatted as markdown.

Returns

str

property html_text: str

Text or caption formatted as HTML

Returns

str

property url: str

Get URL for the message

Returns

str

Generate URL for using in text messages with HTML or MD parse mode

Parameters
  • text – link label

  • as_html – generate as HTML

Returns

str

async answer(text: String, parse_mode: Optional[String] = None, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Answer to this message

Parameters
  • text (base.String) – Text of the message to be sent

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

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

  • disable_web_page_preview (typing.Optional[base.Boolean]) – Disables link previews for links in this message

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async answer_photo(photo: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send photos.

Source: https://core.telegram.org/bots/api#sendphoto

Parameters
  • photo (typing.Union[base.InputFile, base.String]) – Photo to send

  • caption (typing.Optional[base.String]) – Photo caption (may also be used when resending photos by file_id), 0-1024 characters

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async answer_audio(audio: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, performer: Optional[String] = None, title: Optional[String] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.

For sending voice messages, use the sendVoice method instead.

Source: https://core.telegram.org/bots/api#sendaudio

Parameters
  • audio (typing.Union[base.InputFile, base.String]) – Audio file to send.

  • caption (typing.Optional[base.String]) – Audio caption, 0-1024 characters after entities parsing

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • duration (typing.Optional[base.Integer]) – Duration of the audio in seconds

  • performer (typing.Optional[base.String]) – Performer

  • title (typing.Optional[base.String]) – Track name

  • thumb (typing.Union[typing.Union[base.InputFile, base.String], None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_animation(animation: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).

On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

Source https://core.telegram.org/bots/api#sendanimation

Parameters
  • animation (typing.Union[base.InputFile, base.String]) – Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data

  • duration (typing.Optional[base.Integer]) – Duration of sent animation in seconds

  • width (typing.Optional[base.Integer]) – Animation width

  • height (typing.Optional[base.Integer]) – Animation height

  • thumb (typing.Union[typing.Union[base.InputFile, base.String], None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • caption (typing.Optional[base.String]) – Animation caption (may also be used when resending animation by file_id), 0-1024 characters

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async answer_document(document: Union[InputFile, String], thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

Source: https://core.telegram.org/bots/api#senddocument

Parameters
  • document (typing.Union[base.InputFile, base.String]) – File to send

  • thumb (typing.Union[base.InputFile, base.String, None]) – Thumbnail of the file sent

  • caption (typing.Optional[base.String]) – Document caption (may also be used when resending documents by file_id), 0-1024 characters

  • disable_content_type_detection (typing.Optional[base.Boolean]) – Disables automatic server-side content type detection for files uploaded using multipart/form-data

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (typing.Optional[base.Boolean]) – True if the message is a reply

Returns

On success, the sent Message is returned

Return type

types.Message

async answer_video(video: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, supports_streaming: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).

Source: https://core.telegram.org/bots/api#sendvideo

Parameters
  • video (typing.Union[base.InputFile, base.String]) – Video to send.

  • duration (typing.Optional[base.Integer]) – Duration of sent video in seconds

  • width (typing.Optional[base.Integer]) – Video width

  • height (typing.Optional[base.Integer]) – Video height

  • thumb (typing.Union[base.InputFile, base.String, None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • caption (typing.Optional[base.String]) – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • supports_streaming (typing.Optional[base.Boolean]) – Pass True, if the uploaded video is suitable for streaming

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_voice(voice: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.

For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document).

Source: https://core.telegram.org/bots/api#sendvoice

Parameters
  • voice (typing.Union[base.InputFile, base.String]) – Audio file to send.

  • caption (typing.Optional[base.String]) – Voice message caption, 0-1024 characters after entities parsing

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • duration (typing.Optional[base.Integer]) – Duration of the voice message in seconds

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_video_note(video_note: Union[InputFile, String], duration: Optional[Integer] = None, length: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages.

Source: https://core.telegram.org/bots/api#sendvideonote

Parameters
  • video_note (typing.Union[base.InputFile, base.String]) – Video note to send.

  • duration (typing.Optional[base.Integer]) – Duration of sent video in seconds

  • length (typing.Optional[base.Integer]) – Video width and height

  • thumb (typing.Union[typing.Union[base.InputFile, base.String], None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_media_group(media: Union[MediaGroup, List], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply: Boolean = False) List[Message][source]

Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only group in an album with messages of the same type. On success, an array of Messages that were sent is returned.

Source: https://core.telegram.org/bots/api#sendmediagroup

Parameters
  • media (typing.Union[types.MediaGroup, typing.List]) – A JSON-serialized array describing photos and videos to be sent

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, an array of the sent Messages is returned.

Return type

List[types.Message]

async answer_location(latitude: Float, longitude: Float, live_period: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, horizontal_accuracy: Optional[Float] = None, heading: Optional[Integer] = None, proximity_alert_radius: Optional[Integer] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send point on the map.

Source: https://core.telegram.org/bots/api#sendlocation

Parameters
  • latitude (base.Float) – Latitude of the location

  • longitude (base.Float) – Longitude of the location

  • horizontal_accuracy (typing.Optional[base.Float]) – The radius of uncertainty for the location, measured in meters; 0-1500

  • live_period (typing.Optional[base.Integer]) – Period in seconds for which the location will be updated

  • heading (typing.Optional[base.Integer]) – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.

  • proximity_alert_radius (typing.Optional[base.Integer]) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_venue(latitude: Float, longitude: Float, title: String, address: String, foursquare_id: Optional[String] = None, foursquare_type: Optional[String] = None, google_place_id: Optional[String] = None, google_place_type: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send information about a venue.

Source: https://core.telegram.org/bots/api#sendvenue

Parameters
  • latitude (base.Float) – Latitude of the venue

  • longitude (base.Float) – Longitude of the venue

  • title (base.String) – Name of the venue

  • address (base.String) – Address of the venue

  • foursquare_id (typing.Optional[base.String]) – Foursquare identifier of the venue

  • foursquare_type (typing.Optional[base.String]) – Foursquare type of the venue, if known

  • google_place_id (typing.Optional[base.String]) – Google Places identifier of the venue

  • google_place_type (typing.Optional[base.String]) – Google Places type of the venue. See supported types: https://developers.google.com/places/web-service/supported_types

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_contact(phone_number: String, first_name: String, last_name: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send phone contacts.

Source: https://core.telegram.org/bots/api#sendcontact

Parameters
  • phone_number (base.String) – Contact’s phone number

  • first_name (base.String) – Contact’s first name

  • last_name (typing.Optional[base.String]) – Contact’s last name

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_sticker(sticker: Union[InputFile, String], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send .webp stickers.

Source: https://core.telegram.org/bots/api#sendsticker

Parameters
  • sticker (typing.Union[base.InputFile, base.String]) – Sticker to send.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_poll(question: String, options: List[String], is_anonymous: Optional[Boolean] = None, type: Optional[String] = None, allows_multiple_answers: Optional[Boolean] = None, correct_option_id: Optional[Integer] = None, explanation: Optional[String] = None, explanation_parse_mode: Optional[String] = None, explanation_entities: Optional[List[MessageEntity]] = None, open_period: Optional[Integer] = None, close_date: Optional[Union[Integer, datetime, timedelta]] = None, is_closed: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send a native poll. On success, the sent Message is returned.

Source: https://core.telegram.org/bots/api#sendpoll

Parameters
  • question (base.String) – Poll question, 1-255 characters

  • options (typing.List[base.String]) – List of answer options, 2-10 strings 1-100 characters each

  • is_anonymous (typing.Optional[base.Boolean]) – True, if the poll needs to be anonymous, defaults to True

  • type (typing.Optional[base.String]) – Poll type, “quiz” or “regular”, defaults to “regular”

  • allows_multiple_answers (typing.Optional[base.Boolean]) – True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False

  • correct_option_id (typing.Optional[base.Integer]) – 0-based identifier of the correct answer option, required for polls in quiz mode

  • explanation (typing.Optional[base.String]) – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing

  • explanation_parse_mode (typing.Optional[base.String]) – Mode for parsing entities in the explanation. See formatting options for more details.

  • explanation_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • open_period (typing.Optional[base.Integer]) – Amount of time in seconds the poll will be active after creation, 5-600. Can’t be used together with close_date.

  • close_date (typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None]) – Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can’t be used together with open_period.

  • is_closed (typing.Optional[base.Boolean]) – Pass True, if the poll needs to be immediately closed

  • disable_notification (typing.Optional[Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async answer_dice(emoji: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = False) Message[source]

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.

Source: https://core.telegram.org/bots/api#senddice

Parameters
  • emoji (typing.Optional[base.String]) – Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async answer_chat_action(action: String, message_thread_id: Optional[Integer] = None) Boolean[source]

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).

We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.

Source: https://core.telegram.org/bots/api#sendchataction

Parameters
  • action (base.String) – Type of action to broadcast

  • message_thread_id (typing.Optional[base.Integer]) – Unique identifier for the target message thread; supergroups only

Returns

Returns True on success

Return type

base.Boolean

async reply(text: String, parse_mode: Optional[String] = None, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Reply to this message

Parameters
  • text (base.String) – Text of the message to be sent

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

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

  • disable_web_page_preview (typing.Optional[base.Boolean]) – Disables link previews for links in this message

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async reply_photo(photo: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send photos.

Source: https://core.telegram.org/bots/api#sendphoto

Parameters
  • photo (typing.Union[base.InputFile, base.String]) – Photo to send

  • caption (typing.Optional[base.String]) – Photo caption (may also be used when resending photos by file_id), 0-1024 characters

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async reply_audio(audio: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, performer: Optional[String] = None, title: Optional[String] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.

For sending voice messages, use the sendVoice method instead.

Source: https://core.telegram.org/bots/api#sendaudio

Parameters
  • audio (typing.Union[base.InputFile, base.String]) – Audio file to send.

  • caption (typing.Optional[base.String]) – Audio caption, 0-1024 characters after entities parsing

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • duration (typing.Optional[base.Integer]) – Duration of the audio in seconds

  • performer (typing.Optional[base.String]) – Performer

  • title (typing.Optional[base.String]) – Track name

  • thumb (typing.Union[typing.Union[base.InputFile, base.String], None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_animation(animation: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).

On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

Source https://core.telegram.org/bots/api#sendanimation

Parameters
  • animation (typing.Union[base.InputFile, base.String]) – Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data

  • duration (typing.Optional[base.Integer]) – Duration of sent animation in seconds

  • width (typing.Optional[base.Integer]) – Animation width

  • height (typing.Optional[base.Integer]) – Animation height

  • thumb (typing.Union[typing.Union[base.InputFile, base.String], None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • caption (typing.Optional[base.String]) – Animation caption (may also be used when resending animation by file_id), 0-1024 characters

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async reply_document(document: Union[InputFile, String], thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

Source: https://core.telegram.org/bots/api#senddocument

Parameters
  • document (typing.Union[base.InputFile, base.String]) – File to send

  • thumb (typing.Union[base.InputFile, base.String, None]) – Thumbnail of the file sent

  • caption (typing.Optional[base.String]) – Document caption (may also be used when resending documents by file_id), 0-1024 characters

  • disable_content_type_detection (typing.Optional[base.Boolean]) – Disables automatic server-side content type detection for files uploaded using multipart/form-data

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (typing.Optional[base.Boolean]) – True if the message is a reply

Returns

On success, the sent Message is returned

Return type

types.Message

async reply_video(video: Union[InputFile, String], duration: Optional[Integer] = None, width: Optional[Integer] = None, height: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, supports_streaming: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).

Source: https://core.telegram.org/bots/api#sendvideo

Parameters
  • video (typing.Union[base.InputFile, base.String]) – Video to send.

  • duration (typing.Optional[base.Integer]) – Duration of sent video in seconds

  • width (typing.Optional[base.Integer]) – Video width

  • height (typing.Optional[base.Integer]) – Video height

  • thumb (typing.Union[base.InputFile, base.String, None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • caption (typing.Optional[base.String]) – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • supports_streaming (typing.Optional[base.Boolean]) – Pass True, if the uploaded video is suitable for streaming

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_voice(voice: Union[InputFile, String], caption: Optional[String] = None, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.

For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document).

Source: https://core.telegram.org/bots/api#sendvoice

Parameters
  • voice (typing.Union[base.InputFile, base.String]) – Audio file to send.

  • caption (typing.Optional[base.String]) – Voice message caption, 0-1024 characters after entities parsing

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • duration (typing.Optional[base.Integer]) – Duration of the voice message in seconds

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_video_note(video_note: Union[InputFile, String], duration: Optional[Integer] = None, length: Optional[Integer] = None, thumb: Optional[Union[InputFile, String]] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages.

Source: https://core.telegram.org/bots/api#sendvideonote

Parameters
  • video_note (typing.Union[base.InputFile, base.String]) – Video note to send.

  • duration (typing.Optional[base.Integer]) – Duration of sent video in seconds

  • length (typing.Optional[base.Integer]) – Video width and height

  • thumb (typing.Union[typing.Union[base.InputFile, base.String], None]) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (:obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] `) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_media_group(media: Union[MediaGroup, List], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply: Boolean = True) List[Message][source]

Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only group in an album with messages of the same type. On success, an array of Messages that were sent is returned.

Source: https://core.telegram.org/bots/api#sendmediagroup

Parameters
  • media (typing.Union[types.MediaGroup, typing.List]) – A JSON-serialized array describing photos and videos to be sent

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, an array of the sent Messages is returned.

Return type

List[types.Message]

async reply_location(latitude: Float, longitude: Float, live_period: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, horizontal_accuracy: Optional[Float] = None, heading: Optional[Integer] = None, proximity_alert_radius: Optional[Integer] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send point on the map.

Source: https://core.telegram.org/bots/api#sendlocation

Parameters
  • latitude (base.Float) – Latitude of the location

  • longitude (base.Float) – Longitude of the location

  • horizontal_accuracy (typing.Optional[base.Float]) – The radius of uncertainty for the location, measured in meters; 0-1500

  • live_period (typing.Optional[base.Integer]) – Period in seconds for which the location will be updated

  • heading (typing.Optional[base.Integer]) – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.

  • proximity_alert_radius (typing.Optional[base.Integer]) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_venue(latitude: Float, longitude: Float, title: String, address: String, foursquare_id: Optional[String] = None, foursquare_type: Optional[String] = None, google_place_id: Optional[String] = None, google_place_type: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send information about a venue.

Source: https://core.telegram.org/bots/api#sendvenue

Parameters
  • latitude (base.Float) – Latitude of the venue

  • longitude (base.Float) – Longitude of the venue

  • title (base.String) – Name of the venue

  • address (base.String) – Address of the venue

  • foursquare_id (typing.Optional[base.String]) – Foursquare identifier of the venue

  • foursquare_type (typing.Optional[base.String]) – Foursquare type of the venue, if known

  • google_place_id (typing.Optional[base.String]) – Google Places identifier of the venue

  • google_place_type (typing.Optional[base.String]) – Google Places type of the venue. See supported types: https://developers.google.com/places/web-service/supported_types

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_contact(phone_number: String, first_name: String, last_name: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send phone contacts.

Source: https://core.telegram.org/bots/api#sendcontact

Parameters
  • phone_number (base.String) – Contact’s phone number

  • first_name (base.String) – Contact’s first name

  • last_name (typing.Optional[base.String]) – Contact’s last name

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_poll(question: String, options: List[String], is_anonymous: Optional[Boolean] = None, type: Optional[String] = None, allows_multiple_answers: Optional[Boolean] = None, correct_option_id: Optional[Integer] = None, explanation: Optional[String] = None, explanation_parse_mode: Optional[String] = None, explanation_entities: Optional[List[MessageEntity]] = None, open_period: Optional[Integer] = None, close_date: Optional[Union[Integer, datetime, timedelta]] = None, is_closed: Optional[Boolean] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send a native poll. On success, the sent Message is returned.

Source: https://core.telegram.org/bots/api#sendpoll

Parameters
  • question (base.String) – Poll question, 1-255 characters

  • options (typing.List[base.String]) – List of answer options, 2-10 strings 1-100 characters each

  • is_anonymous (typing.Optional[base.Boolean]) – True, if the poll needs to be anonymous, defaults to True

  • type (typing.Optional[base.String]) – Poll type, “quiz” or “regular”, defaults to “regular”

  • allows_multiple_answers (typing.Optional[base.Boolean]) – True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False

  • correct_option_id (typing.Optional[base.Integer]) – 0-based identifier of the correct answer option, required for polls in quiz mode

  • explanation (typing.Optional[base.String]) – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing

  • explanation_parse_mode (typing.Optional[base.String]) – Mode for parsing entities in the explanation. See formatting options for more details.

  • explanation_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • open_period (typing.Optional[base.Integer]) – Amount of time in seconds the poll will be active after creation, 5-600. Can’t be used together with close_date.

  • close_date (typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None]) – Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can’t be used together with open_period.

  • is_closed (typing.Optional[base.Boolean]) – Pass True, if the poll needs to be immediately closed

  • disable_notification (typing.Optional[Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned

Return type

types.Message

async reply_sticker(sticker: Union[InputFile, String], disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send .webp stickers.

Source: https://core.telegram.org/bots/api#sendsticker

Parameters
  • sticker (typing.Union[base.InputFile, base.String]) – Sticker to send.

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async reply_dice(emoji: Optional[String] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None, reply: Boolean = True) Message[source]

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.

Source: https://core.telegram.org/bots/api#senddice

Parameters
  • emoji (typing.Optional[base.String]) – Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of sent messages from forwarding and saving

  • allow_sending_without_reply (typing.Optional[base.Boolean]) – Pass True, if the message should be sent even if the specified replied-to message is not found

  • reply_markup (typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user

  • reply (base.Boolean) – fill ‘reply_to_message_id’

Returns

On success, the sent Message is returned.

Return type

types.Message

async forward(chat_id: Union[Integer, String], message_thread_id: Optional[Integer] = None, disable_notification: Optional[Boolean] = None, protect_content: Optional[Boolean] = None) Message[source]

Forward this message

Source: https://core.telegram.org/bots/api#forwardmessage

Parameters
  • chat_id (typing.Union[base.Integer, base.String]) – Unique identifier for the target chat or username of the target channel

  • message_thread_id (typing.Optional[base.Integer]) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only

  • disable_notification (typing.Optional[base.Boolean]) – Sends the message silently. Users will receive a notification with no sound

  • protect_content (typing.Optional[base.Boolean]) – Protects the contents of the forwarded message from forwarding and saving

Returns

On success, the sent Message is returned

Return type

types.Message

async edit_text(text: String, parse_mode: Optional[String] = None, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[Boolean] = None, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean][source]

Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).

Source: https://core.telegram.org/bots/api#editmessagetext

Parameters
  • text (base.String) – New text of the message

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

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

  • disable_web_page_preview (typing.Optional[base.Boolean]) – Disables link previews for links in this message

  • reply_markup (typing.Optional[types.InlineKeyboardMarkup]) – A JSON-serialized object for an inline keyboard.

Returns

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

Return type

typing.Union[types.Message, base.Boolean]

async edit_caption(caption: String, parse_mode: Optional[String] = None, caption_entities: Optional[List[MessageEntity]] = None, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean][source]

Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).

Source: https://core.telegram.org/bots/api#editmessagecaption

Parameters
  • caption (typing.Optional[base.String]) – New caption of the message

  • parse_mode (typing.Optional[base.String]) – Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.

  • caption_entities (typing.Optional[typing.List[MessageEntity]]) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • reply_markup (typing.Optional[types.InlineKeyboardMarkup]) – A JSON-serialized object for an inline keyboard

Returns

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

Return type

typing.Union[types.Message, base.Boolean]

async edit_media(media: InputMedia, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean][source]

Use this method to edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can’t be uploaded. Use previously uploaded file via its file_id or specify a URL.

On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.

Source https://core.telegram.org/bots/api#editmessagemedia

Parameters
  • media (types.InputMedia) – A JSON-serialized object for a new media content of the message

  • reply_markup (typing.Optional[types.InlineKeyboardMarkup]) – A JSON-serialized object for a new inline keyboard

Returns

On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned

Return type

typing.Union[types.Message, base.Boolean]

async edit_reply_markup(reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean][source]

Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).

Source: https://core.telegram.org/bots/api#editmessagereplymarkup

Parameters

reply_markup (typing.Optional[types.InlineKeyboardMarkup]) – A JSON-serialized object for an inline keyboard

Returns

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

Return type

typing.Union[types.Message, base.Boolean]

async delete_reply_markup() Union[Message, Boolean][source]

Use this method to delete reply markup of messages sent by the bot or via the bot (for inline bots).

Returns

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

Return type

typing.Union[types.Message, base.Boolean]

async edit_live_location(latitude: Float, longitude: Float, reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean][source]

Use this method to edit live location messages sent by the bot or via the bot (for inline bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation.

Source: https://core.telegram.org/bots/api#editmessagelivelocation

Parameters
  • latitude (base.Float) – Latitude of new location

  • longitude (base.Float) – Longitude of new location

  • reply_markup (typing.Optional[types.InlineKeyboardMarkup]) – A JSON-serialized object for a new inline keyboard.

Returns

On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.

Return type

typing.Union[types.Message, base.Boolean]

async stop_live_location(reply_markup: Optional[InlineKeyboardMarkup] = None) Union[Message, Boolean][source]

Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires.

Source: https://core.telegram.org/bots/api#stopmessagelivelocation

Parameters

reply_markup (typing.Optional[types.InlineKeyboardMarkup]) – A JSON-serialized object for a new inline keyboard.

Returns

On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.

Return type

typing.Union[types.Message, base.Boolean]

async delete() Boolean[source]

Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. - Bots can delete incoming messages in private chats. - Bots granted can_post_messages permissions can delete outgoing messages in channels. - If the bot is an administrator of a group, it can delete any message there. - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.

Source: https://core.telegram.org/bots/api#deletemessage

Returns

Returns True on success

Return type

base.Boolean

async pin(disable_notification: Optional[Boolean] = None) Boolean[source]

Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in a supergroup or ‘can_edit_messages’ admin right in a channel. Returns True on success.

Source: https://core.telegram.org/bots/api#pinchatmessage

Parameters

disable_notification (typing.Optional[base.Boolean]) – Pass True, if it is not necessary to send a notification to all group members about the new pinned message

Returns

Returns True on success

Return type

base.Boolean

async unpin() Boolean[source]

Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in a supergroup or ‘can_edit_messages’ admin right in a channel. Returns True on success.

Source: https://core.telegram.org/bots/api#unpinchatmessage

Returns

Returns True on success

Return type

base.Boolean

async send_copy(chat_id: Union[str, int], message_thread_id: Optional[Integer] = None, disable_notification: Optional[bool] = None, protect_content: Optional[Boolean] = None, disable_web_page_preview: Optional[bool] = None, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[Boolean] = None, reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None) Message[source]

Send copy of current message

Parameters
  • chat_id

  • message_thread_id

  • disable_notification

  • protect_content

  • disable_web_page_preview – for text messages only

  • reply_to_message_id

  • allow_sending_without_reply

  • reply_markup

Returns

ContentType

class aiogram.types.message.ContentType[source]

Bases: Helper

List of message content types

WARNING: Single elements

Key

TEXT

Key

AUDIO

Key

DOCUMENT

Key

GAME

Key

PHOTO

Key

STICKER

Key

VIDEO

Key

VIDEO_NOTE

Key

VOICE

Key

CONTACT

Key

LOCATION

Key

VENUE

Key

POLL

Key

DICE

Key

NEW_CHAT_MEMBERS

Key

LEFT_CHAT_MEMBER

Key

INVOICE

Key

SUCCESSFUL_PAYMENT

Key

CONNECTED_WEBSITE

Key

MIGRATE_TO_CHAT_ID

Key

MIGRATE_FROM_CHAT_ID

Key

UNKNOWN

Key

ANY

ContentTypes

class aiogram.types.message.ContentTypes[source]

Bases: Helper

List of message content types

WARNING: List elements.

Key

TEXT

Key

AUDIO

Key

DOCUMENT

Key

GAME

Key

PHOTO

Key

STICKER

Key

VIDEO

Key

VIDEO_NOTE

Key

VOICE

Key

CONTACT

Key

LOCATION

Key

VENUE

Key

POLL

Key

DICE

Key

NEW_CHAT_MEMBERS

Key

LEFT_CHAT_MEMBER

Key

INVOICE

Key

SUCCESSFUL_PAYMENT

Key

CONNECTED_WEBSITE

Key

MIGRATE_TO_CHAT_ID

Key

MIGRATE_FROM_CHAT_ID

Key

UNKNOWN

Key

ANY

ParseMode

class aiogram.types.message.ParseMode[source]

Bases: Helper

Parse modes

Key

MARKDOWN

Key

HTML