Skip to main content
The Update struct represents a single incoming Telegram update. Each update contains exactly one populated field.

Update

type Update struct {
    ID int `json:"update_id"`

    Message                 *Message                 `json:"message,omitempty"`
    EditedMessage           *Message                 `json:"edited_message,omitempty"`
    ChannelPost             *Message                 `json:"channel_post,omitempty"`
    EditedChannelPost       *Message                 `json:"edited_channel_post,omitempty"`
    MessageReaction         *MessageReaction         `json:"message_reaction"`
    MessageReactionCount    *MessageReactionCount    `json:"message_reaction_count"`
    Callback                *Callback                `json:"callback_query,omitempty"`
    Query                   *Query                   `json:"inline_query,omitempty"`
    InlineResult            *InlineResult            `json:"chosen_inline_result,omitempty"`
    ShippingQuery           *ShippingQuery           `json:"shipping_query,omitempty"`
    PreCheckoutQuery        *PreCheckoutQuery        `json:"pre_checkout_query,omitempty"`
    Poll                    *Poll                    `json:"poll,omitempty"`
    PollAnswer              *PollAnswer              `json:"poll_answer,omitempty"`
    MyChatMember            *ChatMemberUpdate        `json:"my_chat_member,omitempty"`
    ChatMember              *ChatMemberUpdate        `json:"chat_member,omitempty"`
    ChatJoinRequest         *ChatJoinRequest         `json:"chat_join_request,omitempty"`
    Boost                   *BoostUpdated            `json:"chat_boost"`
    BoostRemoved            *BoostRemoved            `json:"removed_chat_boost"`
    BusinessConnection      *BusinessConnection      `json:"business_connection"`
    BusinessMessage         *Message                 `json:"business_message"`
    EditedBusinessMessage   *Message                 `json:"edited_business_message"`
    DeletedBusinessMessages *BusinessMessagesDeleted `json:"deleted_business_messages"`
    PurchasedPaidMedia      *PaidMediaPurchased      `json:"purchased_paid_media"`
}

Fields

ID
int
Unique update identifier. JSON: update_id.
Message
*Message
New incoming message of any kind — text, photo, sticker, etc.
EditedMessage
*Message
New version of a message that was edited.
ChannelPost
*Message
New channel post of any kind.
EditedChannelPost
*Message
New version of a channel post that was edited.
MessageReaction
*MessageReaction
A user changed a reaction on a message.
MessageReactionCount
*MessageReactionCount
Reactions to a message with anonymous reactions were changed.
Callback
*Callback
Incoming callback query from an inline keyboard. JSON: callback_query.
Query
*Query
New incoming inline query. JSON: inline_query.
InlineResult
*InlineResult
The result of an inline query chosen by a user. JSON: chosen_inline_result.
ShippingQuery
*ShippingQuery
New incoming shipping query (requires invoices with flexible pricing).
PreCheckoutQuery
*PreCheckoutQuery
New incoming pre-checkout query (final confirmation before payment).
Poll
*Poll
New poll state (sent when a poll is stopped or its settings change).
PollAnswer
*PollAnswer
A user changed their vote in a non-anonymous poll.
MyChatMember
*ChatMemberUpdate
The bot’s chat member status changed in a chat.
ChatMember
*ChatMemberUpdate
A chat member’s status changed. Requires the chat_member allowed update type.
ChatJoinRequest
*ChatJoinRequest
A request to join a chat was sent.
Boost
*BoostUpdated
A chat boost was added or changed. JSON: chat_boost.
BoostRemoved
*BoostRemoved
A chat boost was removed. JSON: removed_chat_boost.
BusinessConnection
*BusinessConnection
The bot was connected or disconnected from a business account.
BusinessMessage
*Message
New message from a connected business account.
EditedBusinessMessage
*Message
New version of a message from a connected business account.
DeletedBusinessMessages
*BusinessMessagesDeleted
Messages were deleted from a connected business account.
PurchasedPaidMedia
*PaidMediaPurchased
A user purchased paid media sent by the bot.

Event Endpoint Constants

Telebot maps update fields to string endpoint constants. Register handlers with b.Handle(endpoint, handlerFunc).

Message Events

ConstantTrigger
OnTextMessage.Text != "" (non-command)
OnForwardMessage.Origin != nil
OnReplyText message that is a reply
OnEditedEditedMessage != nil
OnPhotoMessage.Photo != nil
OnAudioMessage.Audio != nil
OnAnimationMessage.Animation != nil
OnDocumentMessage.Document != nil
OnStickerMessage.Sticker != nil
OnVideoMessage.Video != nil
OnVoiceMessage.Voice != nil
OnVideoNoteMessage.VideoNote != nil
OnContactMessage.Contact != nil
OnLocationMessage.Location != nil
OnVenueMessage.Venue != nil
OnDiceMessage.Dice != nil
OnInvoiceMessage.Invoice != nil
OnPaymentMessage.Payment != nil
OnRefundMessage.RefundedPayment != nil
OnGameMessage.Game != nil
OnPinnedMessage.PinnedMessage != nil
OnMediaAny media type not handled by a specific handler

Channel and Callback Events

ConstantTrigger
OnChannelPostChannelPost != nil
OnEditedChannelPostEditedChannelPost != nil
OnCallbackCallback != nil (unrouted)
OnQueryQuery != nil
OnInlineResultInlineResult != nil
OnShippingShippingQuery != nil
OnCheckoutPreCheckoutQuery != nil
OnPollPoll != nil
OnPollAnswerPollAnswer != nil

Group / Chat Events

ConstantTrigger
OnAddedToGroupBot added to a group
OnUserJoinedMessage.UserJoined != nil
OnUserLeftMessage.UserLeft != nil
OnUserSharedMessage.UserShared != nil
OnChatSharedMessage.ChatShared != nil
OnNewGroupTitleMessage.NewGroupTitle != ""
OnNewGroupPhotoMessage.NewGroupPhoto != nil
OnGroupPhotoDeletedMessage.GroupPhotoDeleted == true
OnGroupCreatedMessage.GroupCreated == true
OnSuperGroupCreatedMessage.SuperGroupCreated == true
OnChannelCreatedMessage.ChannelCreated == true
OnMigrationMessage.MigrateTo != 0
OnMyChatMemberMyChatMember != nil
OnChatMemberChatMember != nil
OnChatJoinRequestChatJoinRequest != nil

Forum Topic Events

ConstantTrigger
OnTopicCreatedMessage.TopicCreated != nil
OnTopicReopenedMessage.TopicReopened != nil
OnTopicClosedMessage.TopicClosed != nil
OnTopicEditedMessage.TopicEdited != nil
OnGeneralTopicHiddenMessage.GeneralTopicHidden != nil
OnGeneralTopicUnhiddenMessage.GeneralTopicUnhidden != nil

Boost, Business & Other Events

ConstantTrigger
OnBoostBoost != nil
OnBoostRemovedBoostRemoved != nil
OnBusinessConnectionBusinessConnection != nil
OnBusinessMessageBusinessMessage != nil
OnEditedBusinessMessageEditedBusinessMessage != nil
OnDeletedBusinessMessagesDeletedBusinessMessages != nil
OnPurchasedPaidMediaPurchasedPaidMedia != nil
OnWebAppMessage.WebAppData != nil
OnProximityAlertMessage.ProximityAlert != nil
OnAutoDeleteTimerMessage.AutoDeleteTimer != nil
OnVideoChatStartedMessage.VideoChatStarted != nil
OnVideoChatEndedMessage.VideoChatEnded != nil
OnVideoChatParticipantsMessage.VideoChatParticipants != nil
OnVideoChatScheduledMessage.VideoChatScheduled != nil
OnWriteAccessAllowedMessage.WriteAccessAllowed != nil
All Telebot endpoint constants begin with the \a (alert) character to avoid collision with real command strings.

AllowedUpdates

AllowedUpdates is a package-level slice listing all update type strings you can request from the Telegram API:
var AllowedUpdates = []string{
    "message",
    "edited_message",
    "channel_post",
    "edited_channel_post",
    "message_reaction",
    "message_reaction_count",
    "inline_query",
    "chosen_inline_result",
    "callback_query",
    "shipping_query",
    "pre_checkout_query",
    "poll",
    "poll_answer",
    "my_chat_member",
    "chat_member",
    "chat_join_request",
    "chat_boost",
    "removed_chat_boost",
}
Pass a subset of these to LongPoller.AllowedUpdates to limit which update types are delivered to your bot:
pref := tele.Settings{
    Token: os.Getenv("TOKEN"),
    Poller: &tele.LongPoller{
        Timeout:        10 * time.Second,
        AllowedUpdates: []string{"message", "callback_query"},
    },
}

LongPoller

type LongPoller struct {
    Limit          int
    Timeout        time.Duration
    LastUpdateID   int
    AllowedUpdates []string `yaml:"allowed_updates"`
}
The default long-polling implementation. Limit sets the maximum number of updates to fetch per request (1–100). Timeout is the long-poll timeout in seconds.

MiddlewarePoller

type MiddlewarePoller struct {
    Capacity int
    Poller   Poller
    Filter   func(*Update) bool
}

func NewMiddlewarePoller(original Poller, filter func(*Update) bool) *MiddlewarePoller
Wraps another Poller and drops updates for which Filter returns false. Useful for spam filtering or allowlisting specific chats.
poller := tele.NewMiddlewarePoller(
    &tele.LongPoller{Timeout: 10 * time.Second},
    func(u *tele.Update) bool {
        if u.Message == nil {
            return true
        }
        return allowedChatIDs[u.Message.Chat.ID]
    },
)

Build docs developers (and LLMs) love