Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Update

class telegram.Update(update_id, message=None, edited_message=None, channel_post=None, edited_channel_post=None, inline_query=None, chosen_inline_result=None, callback_query=None, shipping_query=None, pre_checkout_query=None, poll=None, poll_answer=None, my_chat_member=None, chat_member=None, chat_join_request=None, chat_boost=None, removed_chat_boost=None, message_reaction=None, message_reaction_count=None, business_connection=None, business_message=None, edited_business_message=None, deleted_business_messages=None, purchased_paid_media=None, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  This object represents an incoming update.

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their `update_id` is equal.

  Note

  At most one of the optional parameters can be present in any given update.

  See also

  Your First Bot

  Parameters:

    - update_id (`int`) – The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

    - message (`telegram.Message`, optional) – New incoming message of any kind - text, photo, sticker, etc.

    - edited_message (`telegram.Message`, optional) – New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

    - channel_post (`telegram.Message`, optional) – New incoming channel post of any kind - text, photo, sticker, etc.

    - edited_channel_post (`telegram.Message`, optional) – New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

    - inline_query (`telegram.InlineQuery`, optional) – New incoming inline query.

    - chosen_inline_result (`telegram.ChosenInlineResult`, optional) – The result of an inline query that was chosen by a user and sent to their chat partner.

    - callback_query (`telegram.CallbackQuery`, optional) – New incoming callback query.

    - shipping_query (`telegram.ShippingQuery`, optional) – New incoming shipping query. Only for invoices with flexible price.

    - pre_checkout_query (`telegram.PreCheckoutQuery`, optional) – New incoming pre-checkout query. Contains full information about checkout.

    - poll (`telegram.Poll`, optional) – New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot.

    - poll_answer (`telegram.PollAnswer`, optional) – A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

    - my_chat_member (`telegram.ChatMemberUpdated`, optional) –

      The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

      Added in version 13.4.

    - chat_member (`telegram.ChatMemberUpdated`, optional) –

      A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify `CHAT_MEMBER` in the list of `telegram.ext.Application.run_polling.allowed_updates` to receive these updates (see `telegram.Bot.get_updates()`, `telegram.Bot.set_webhook()`, `telegram.ext.Application.run_polling()` and `telegram.ext.Application.run_webhook()`).

      Added in version 13.4.

    - chat_join_request (`telegram.ChatJoinRequest`, optional) –

      A request to join the chat has been sent. The bot must have the `telegram.ChatPermissions.can_invite_users` administrator right in the chat to receive these updates.

      Added in version 13.8.

    - chat_boost (`telegram.ChatBoostUpdated`, optional) –

      A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.

      Added in version 20.8.

    - removed_chat_boost (`telegram.ChatBoostRemoved`, optional) –

      A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.

      Added in version 20.8.

    - message_reaction (`telegram.MessageReactionUpdated`, optional) –

      A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify `MESSAGE_REACTION` in the list of `telegram.ext.Application.run_polling.allowed_updates` to receive these updates (see `telegram.Bot.get_updates()`, `telegram.Bot.set_webhook()`, `telegram.ext.Application.run_polling()` and `telegram.ext.Application.run_webhook()`). The update isn’t received for reactions set by bots.

      Added in version 20.8.

    - message_reaction_count (`telegram.MessageReactionCountUpdated`, optional) –

      Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify `MESSAGE_REACTION_COUNT` in the list of `telegram.ext.Application.run_polling.allowed_updates` to receive these updates (see `telegram.Bot.get_updates()`, `telegram.Bot.set_webhook()`, `telegram.ext.Application.run_polling()` and `telegram.ext.Application.run_webhook()`). The updates are grouped and can be sent with delay up to a few minutes.

      Added in version 20.8.

    - business_connection (`telegram.BusinessConnection`, optional) –

      The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot.

      Added in version 21.1.

    - business_message (`telegram.Message`, optional) –

      New message from a connected business account.

      Added in version 21.1.

    - edited_business_message (`telegram.Message`, optional) –

      New version of a message from a connected business account.

      Added in version 21.1.

    - deleted_business_messages (`telegram.BusinessMessagesDeleted`, optional) –

      Messages were deleted from a connected business account.

      Added in version 21.1.

    - purchased_paid_media (`telegram.PaidMediaPurchased`, optional) –

      A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat.

      Added in version 21.6.

  update_id

    The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

    Type:

      `int`

  message

    Optional. New incoming message of any kind - text, photo, sticker, etc.

    Type:

      `telegram.Message`

  edited_message

    Optional. New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

    Type:

      `telegram.Message`

  channel_post

    Optional. New incoming channel post of any kind - text, photo, sticker, etc.

    Type:

      `telegram.Message`

  edited_channel_post

    Optional. New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

    Type:

      `telegram.Message`

  inline_query

    Optional. New incoming inline query.

    Type:

      `telegram.InlineQuery`

  chosen_inline_result

    Optional. The result of an inline query that was chosen by a user and sent to their chat partner.

    Type:

      `telegram.ChosenInlineResult`

  callback_query

    Optional. New incoming callback query.

    Examples

    Arbitrary Callback Data Bot

    Type:

      `telegram.CallbackQuery`

  shipping_query

    Optional. New incoming shipping query. Only for invoices with flexible price.

    Type:

      `telegram.ShippingQuery`

  pre_checkout_query

    Optional. New incoming pre-checkout query. Contains full information about checkout.

    Type:

      `telegram.PreCheckoutQuery`

  poll

    Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot.

    Type:

      `telegram.Poll`

  poll_answer

    Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

    Type:

      `telegram.PollAnswer`

  my_chat_member

    Optional. The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

    Added in version 13.4.

    Type:

      `telegram.ChatMemberUpdated`

  chat_member

    Optional. A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify `CHAT_MEMBER` in the list of `telegram.ext.Application.run_polling.allowed_updates` to receive these updates (see `telegram.Bot.get_updates()`, `telegram.Bot.set_webhook()`, `telegram.ext.Application.run_polling()` and `telegram.ext.Application.run_webhook()`).

    Added in version 13.4.

    Type:

      `telegram.ChatMemberUpdated`

  chat_join_request

    Optional. A request to join the chat has been sent. The bot must have the `telegram.ChatPermissions.can_invite_users` administrator right in the chat to receive these updates.

    Added in version 13.8.

    Type:

      `telegram.ChatJoinRequest`

  chat_boost

    Optional. A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.

    Added in version 20.8.

    Type:

      `telegram.ChatBoostUpdated`

  removed_chat_boost

    Optional. A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.

    Added in version 20.8.

    Type:

      `telegram.ChatBoostRemoved`

  message_reaction

    Optional. A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify `MESSAGE_REACTION` in the list of `telegram.ext.Application.run_polling.allowed_updates` to receive these updates (see `telegram.Bot.get_updates()`, `telegram.Bot.set_webhook()`, `telegram.ext.Application.run_polling()` and `telegram.ext.Application.run_webhook()`). The update isn’t received for reactions set by bots.

    Added in version 20.8.

    Type:

      `telegram.MessageReactionUpdated`

  message_reaction_count

    Optional. Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify `MESSAGE_REACTION_COUNT` in the list of `telegram.ext.Application.run_polling.allowed_updates` to receive these updates (see `telegram.Bot.get_updates()`, `telegram.Bot.set_webhook()`, `telegram.ext.Application.run_polling()` and `telegram.ext.Application.run_webhook()`). The updates are grouped and can be sent with delay up to a few minutes.

    Added in version 20.8.

    Type:

      `telegram.MessageReactionCountUpdated`

  business_connection

    Optional. The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot.

    Added in version 21.1.

    Type:

      `telegram.BusinessConnection`

  business_message

    Optional. New message from a connected business account.

    Added in version 21.1.

    Type:

      `telegram.Message`

  edited_business_message

    Optional. New version of a message from a connected business account.

    Added in version 21.1.

    Type:

      `telegram.Message`

  deleted_business_messages

    Optional. Messages were deleted from a connected business account.

    Added in version 21.1.

    Type:

      `telegram.BusinessMessagesDeleted`

  purchased_paid_media

    Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat.

    Added in version 21.6.

    Type:

      `telegram.PaidMediaPurchased`

  ALL_TYPES = [<UpdateType.MESSAGE>, <UpdateType.EDITED_MESSAGE>, <UpdateType.CHANNEL_POST>, <UpdateType.EDITED_CHANNEL_POST>, <UpdateType.INLINE_QUERY>, <UpdateType.CHOSEN_INLINE_RESULT>, <UpdateType.CALLBACK_QUERY>, <UpdateType.SHIPPING_QUERY>, <UpdateType.PRE_CHECKOUT_QUERY>, <UpdateType.POLL>, <UpdateType.POLL_ANSWER>, <UpdateType.MY_CHAT_MEMBER>, <UpdateType.CHAT_MEMBER>, <UpdateType.CHAT_JOIN_REQUEST>, <UpdateType.CHAT_BOOST>, <UpdateType.REMOVED_CHAT_BOOST>, <UpdateType.MESSAGE_REACTION>, <UpdateType.MESSAGE_REACTION_COUNT>, <UpdateType.BUSINESS_CONNECTION>, <UpdateType.BUSINESS_MESSAGE>, <UpdateType.EDITED_BUSINESS_MESSAGE>, <UpdateType.DELETED_BUSINESS_MESSAGES>, <UpdateType.PURCHASED_PAID_MEDIA>]

    A list of all available update types.

    Added in version 13.5.

    Type:

      list[`str`]

  BUSINESS_CONNECTION = 'business_connection'

    `telegram.constants.UpdateType.BUSINESS_CONNECTION`

    Added in version 21.1.

  BUSINESS_MESSAGE = 'business_message'

    `telegram.constants.UpdateType.BUSINESS_MESSAGE`

    Added in version 21.1.

  CALLBACK_QUERY = 'callback_query'

    `telegram.constants.UpdateType.CALLBACK_QUERY`

    Added in version 13.5.

  CHANNEL_POST = 'channel_post'

    `telegram.constants.UpdateType.CHANNEL_POST`

    Added in version 13.5.

  CHAT_BOOST = 'chat_boost'

    `telegram.constants.UpdateType.CHAT_BOOST`

    Added in version 20.8.

  CHAT_JOIN_REQUEST = 'chat_join_request'

    `telegram.constants.UpdateType.CHAT_JOIN_REQUEST`

    Added in version 13.8.

  CHAT_MEMBER = 'chat_member'

    `telegram.constants.UpdateType.CHAT_MEMBER`

    Added in version 13.5.

  CHOSEN_INLINE_RESULT = 'chosen_inline_result'

    `telegram.constants.UpdateType.CHOSEN_INLINE_RESULT`

    Added in version 13.5.

  DELETED_BUSINESS_MESSAGES = 'deleted_business_messages'

    `telegram.constants.UpdateType.DELETED_BUSINESS_MESSAGES`

    Added in version 21.1.

  EDITED_BUSINESS_MESSAGE = 'edited_business_message'

    `telegram.constants.UpdateType.EDITED_BUSINESS_MESSAGE`

    Added in version 21.1.

  EDITED_CHANNEL_POST = 'edited_channel_post'

    `telegram.constants.UpdateType.EDITED_CHANNEL_POST`

    Added in version 13.5.

  EDITED_MESSAGE = 'edited_message'

    `telegram.constants.UpdateType.EDITED_MESSAGE`

    Added in version 13.5.

  INLINE_QUERY = 'inline_query'

    `telegram.constants.UpdateType.INLINE_QUERY`

    Added in version 13.5.

  MESSAGE = 'message'

    `telegram.constants.UpdateType.MESSAGE`

    Added in version 13.5.

  MESSAGE_REACTION = 'message_reaction'

    `telegram.constants.UpdateType.MESSAGE_REACTION`

    Added in version 20.8.

  MESSAGE_REACTION_COUNT = 'message_reaction_count'

    `telegram.constants.UpdateType.MESSAGE_REACTION_COUNT`

    Added in version 20.8.

  MY_CHAT_MEMBER = 'my_chat_member'

    `telegram.constants.UpdateType.MY_CHAT_MEMBER`

    Added in version 13.5.

  POLL = 'poll'

    `telegram.constants.UpdateType.POLL`

    Added in version 13.5.

  POLL_ANSWER = 'poll_answer'

    `telegram.constants.UpdateType.POLL_ANSWER`

    Added in version 13.5.

  PRE_CHECKOUT_QUERY = 'pre_checkout_query'

    `telegram.constants.UpdateType.PRE_CHECKOUT_QUERY`

    Added in version 13.5.

  PURCHASED_PAID_MEDIA = 'purchased_paid_media'

    `telegram.constants.UpdateType.PURCHASED_PAID_MEDIA`

    Added in version 21.6.

  REMOVED_CHAT_BOOST = 'removed_chat_boost'

    `telegram.constants.UpdateType.REMOVED_CHAT_BOOST`

    Added in version 20.8.

  SHIPPING_QUERY = 'shipping_query'

    `telegram.constants.UpdateType.SHIPPING_QUERY`

    Added in version 13.5.

  classmethod de_json(data, bot=None)

    See `telegram.TelegramObject.de_json()`.

  property effective_chat

    The chat that this update was sent in, no matter what kind of update this is. If no chat is associated with this update, this gives `None`. This is the case, if `inline_query`, `chosen_inline_result`, `callback_query` from inline messages, `shipping_query`, `pre_checkout_query`, `poll`, `poll_answer`, `business_connection`, or `purchased_paid_media` is present.

    Changed in version 21.1: This property now also considers `business_message`, `edited_business_message`, and `deleted_business_messages`.

    Example

    If `message` is present, this will give `telegram.Message.chat`.

    Type:

      `telegram.Chat`

  property effective_message
    The message included in this update, no matter what kind of

      update this is. More precisely, this will be the message contained in `message`, `edited_message`, `channel_post`, `edited_channel_post` or `callback_query` (i.e. `telegram.CallbackQuery.message`) or `None`, if none of those are present.

    Changed in version 21.1: This property now also considers `business_message`, and `edited_business_message`.

    Tip

    This property will only ever return objects of type `telegram.Message` or `None`, never `telegram.MaybeInaccessibleMessage` or `telegram.InaccessibleMessage`. Currently, this is only relevant for `callback_query`, as `telegram.CallbackQuery.message` is the only attribute considered by this property that can be an object of these types.

    Type:

      `telegram.Message`

  property effective_sender

    The user or chat that sent this update, no matter what kind of update this is.

    Note

    - Depending on the type of update and the user’s ‘Remain anonymous’ setting, this could either be `telegram.User`, `telegram.Chat` or `None`.

    If no user whatsoever is associated with this update, this gives `None`. This is the case if any of

    - `poll`

    - `chat_boost`

    - `removed_chat_boost`

    - `message_reaction_count`

    - `deleted_business_messages`

    is present.

    Example

    - If `message` is present, this will give either `telegram.Message.from_user` or `telegram.Message.sender_chat`.

    - If `poll_answer` is present, this will give either `telegram.PollAnswer.user` or `telegram.PollAnswer.voter_chat`.

    - If `channel_post` is present, this will give `telegram.Message.sender_chat`.

    Added in version 21.1.

    Type:

      `telegram.User` or `telegram.Chat`

  property effective_user

    The user that sent this update, no matter what kind of update this is. If no user is associated with this update, this gives `None`. This is the case if any of

    - `channel_post`

    - `edited_channel_post`

    - `poll`

    - `chat_boost`

    - `removed_chat_boost`

    - `message_reaction_count`

    - `deleted_business_messages`

    is present.

    Changed in version 21.1: This property now also considers `business_connection`, `business_message` and `edited_business_message`.

    Changed in version 21.6: This property now also considers `purchased_paid_media`.

    Example

    - If `message` is present, this will give `telegram.Message.from_user`.

    - If `poll_answer` is present, this will give `telegram.PollAnswer.user`.

    Type:

      `telegram.User`