Skip to main content
The Message struct represents a Telegram message and is returned by most send/edit operations.

Message

type Message struct { ... }

Core Fields

ID
int
Unique message identifier inside the chat. JSON: message_id.
ThreadID
int
Thread (topic) identifier for supergroup forum messages. JSON: message_thread_id.
Sender
*User
The user who sent the message. nil for channel posts.
Unixtime
int64
Unix timestamp of the message. Use Message.Time() to obtain a time.Time.
Chat
*Chat
The conversation the message belongs to.
SenderChat
*Chat
Sender chat when a message is sent on behalf of a chat.

Text and Caption

Text
string
UTF-8 text content for plain text messages.
Payload
string
Command arguments extracted from the message text. For /start deep-link, this holds the deep-link parameter. Not serialized from JSON — populated by Telebot during update processing.
b.Handle("/start", func(c tele.Context) error {
    ref := c.Message().Payload // deep-link value
    return c.Send("Hello, " + ref)
})
Entities
Entities
Special entities in Text (mentions, URLs, commands, etc.).
Caption
string
Caption for media messages (photo, video, etc.).
CaptionEntities
Entities
Special entities in Caption.
EffectID
string
Unique identifier of a message effect applied to the message.

Forward / Reply Info

OriginalSender
*User
Original sender for forwarded messages. JSON: forward_from.
OriginalChat
*Chat
Original channel chat for forwarded channel posts. JSON: forward_from_chat.
OriginalMessageID
int
Original message identifier for forwarded channel posts.
OriginalUnixtime
int
Unix timestamp of the original forwarded message.
Origin
*MessageOrigin
Structured origin information for forwarded messages (forward_origin).
AutomaticForward
bool
true when the message is a channel post automatically forwarded to the linked discussion group.
ReplyTo
*Message
The message being replied to. Does not contain nested ReplyTo.
ExternalReply
*ExternalReply
Information about a reply to a message from another chat or topic.
Quote
*TextQuote
The quoted portion of the replied-to message.
Via
*User
Bot through which the message was sent (inline mode). JSON: via_bot.

Media Fields

Photo
*Photo
Highest-resolution photo thumbnail.
Audio
*Audio
Audio file information.
Video
*Video
Video file information.
Document
*Document
General file information.
Voice
*Voice
Voice message information.
VideoNote
*VideoNote
Video note (round video) information.
Animation
*Animation
GIF or H.264 animation information.
Sticker
*Sticker
Sticker information.
Contact
*Contact
Shared contact.
Location
*Location
Shared geographic location.
Venue
*Venue
Venue information.
Poll
*Poll
Native poll.
Game
*Game
Game information.
Dice
*Dice
Animated dice result.
PaidMedia
PaidMedias
Paid media content attached to the message.

Service Message Fields

UserJoined
*User
User who just joined the chat. JSON: new_chat_member.
UsersJoined
[]User
Multiple users who joined simultaneously. JSON: new_chat_members.
UserLeft
*User
User who left the chat. JSON: left_chat_member.
NewGroupTitle
string
New chat title service message.
NewGroupPhoto
*Photo
New chat photo service message.
GroupCreated
bool
true if the group was just created.
SuperGroupCreated
bool
true if a supergroup was just created.
ChannelCreated
bool
true if a channel was just created.
MigrateTo
int64
The supergroup chat ID that this group migrated to.
MigrateFrom
int64
The old group chat ID that this supergroup migrated from.
PinnedMessage
*Message
Service message about a pinned message.
Invoice
*Invoice
Invoice for a payment.
Payment
*Payment
Service message about a successful payment. JSON: successful_payment.
RefundedPayment
*RefundedPayment
Service message about a refunded payment.
Protected
bool
true if the message content is protected from forwarding and saving.
AlbumID
string
Media group identifier — all messages in the same album share this ID. JSON: media_group_id.
Signature
string
Author signature for channel posts.
TopicMessage
bool
true if sent inside a forum topic.
ReplyMarkup
*ReplyMarkup
Inline keyboard attached to the message.
LastEdit
int64
Unix timestamp of the last edit. Use Message.LastEdited() to get time.Time.
BusinessConnectionID
string
Identifier of the business connection the message belongs to.

Methods

Time

func (m *Message) Time() time.Time
Returns the message creation time in local time.

LastEdited

func (m *Message) LastEdited() time.Time
Returns the time of the last edit in local time.

MessageSig

func (m *Message) MessageSig() (string, int64)
Implements the Editable interface. Returns (strconv.Itoa(m.ID), m.Chat.ID).

Inaccessible

func (m *Message) Inaccessible() bool
Returns true when the message is an inaccessible message object (sender is nil).

IsForwarded

func (m *Message) IsForwarded() bool
Returns true if the message is a forwarded copy.

IsReply

func (m *Message) IsReply() bool
Returns true if the message is a reply to another message.

Private

func (m *Message) Private() bool
Returns true for direct/private messages.

FromGroup

func (m *Message) FromGroup() bool
Returns true for group or supergroup messages.

FromChannel

func (m *Message) FromChannel() bool
Returns true for channel posts.

IsService

func (m *Message) IsService() bool
Returns true for service messages (joins, title changes, migrations, etc.).

Media

func (m *Message) Media() Media
Returns the first media attachment found (photo, voice, audio, animation, sticker, document, video, video note). Returns nil if none.

EntityText

func (m *Message) EntityText(e MessageEntity) string
Extracts the substring identified by the given entity using correct UTF-16 indexing.

MessageEntity

type MessageEntity struct {
    Type          EntityType `json:"type"`
    Offset        int        `json:"offset"`
    Length        int        `json:"length"`
    URL           string     `json:"url,omitempty"`
    User          *User      `json:"user,omitempty"`
    Language      string     `json:"language,omitempty"`
    CustomEmojiID string     `json:"custom_emoji_id,omitempty"`
    ChatUsername  string     `json:"chat_username,omitempty"`
}
Type
EntityType
The entity type.
Offset
int
Start offset in UTF-16 code units.
Length
int
Length in UTF-16 code units.
URL
string
URL for EntityTextLink type.
User
*User
User for EntityTMention type.
Language
string
Programming language for EntityCodeBlock type.
CustomEmojiID
string
Custom emoji ID for EntityCustomEmoji type.

Entity Type Constants

const (
    EntityMention       EntityType = "mention"
    EntityTMention      EntityType = "text_mention"
    EntityHashtag       EntityType = "hashtag"
    EntityCashtag       EntityType = "cashtag"
    EntityCommand       EntityType = "bot_command"
    EntityURL           EntityType = "url"
    EntityEmail         EntityType = "email"
    EntityPhone         EntityType = "phone_number"
    EntityBold          EntityType = "bold"
    EntityItalic        EntityType = "italic"
    EntityUnderline     EntityType = "underline"
    EntityStrikethrough EntityType = "strikethrough"
    EntityCode          EntityType = "code"
    EntityCodeBlock     EntityType = "pre"
    EntityTextLink      EntityType = "text_link"
    EntitySpoiler       EntityType = "spoiler"
    EntityCustomEmoji   EntityType = "custom_emoji"
    EntityBlockquote    EntityType = "blockquote"
    EntityEBlockquote   EntityType = "expandable_blockquote"
)
Entities is a named type alias:
type Entities []MessageEntity

StoredMessage

A convenience struct suitable for storing in a database and later using as an Editable.
type StoredMessage struct {
    MessageID string `sql:"message_id" json:"message_id"`
    ChatID    int64  `sql:"chat_id" json:"chat_id"`
}

func (x StoredMessage) MessageSig() (string, int64)
// Store a message reference
stored := tele.StoredMessage{
    MessageID: strconv.Itoa(msg.ID),
    ChatID:    msg.Chat.ID,
}

// Later, edit using the stored reference
b.Edit(stored, "updated text")

MessageOrigin

Describes the original source of a forwarded message.
type MessageOrigin struct {
    Type         string `json:"type"`
    DateUnixtime int64  `json:"date"`
    Sender       *User  `json:"sender_user,omitempty"`
    SenderUsername string `json:"sender_user_name,omitempty"`
    SenderChat   *Chat  `json:"sender_chat,omitempty"`
    Chat         *Chat  `json:"chat,omitempty"`
    MessageID    int    `json:"message_id,omitempty"`
    Signature    string `json:"author_signature,omitempty"`
}
Call mo.Time() to obtain the original send time as time.Time.

TextQuote

Contains the quoted portion of a replied-to message.
type TextQuote struct {
    Text     string          `json:"text"`
    Entities []MessageEntity `json:"entities"`
    Position int             `json:"position"`
    Manual   bool            `json:"is_manual"`
}

Build docs developers (and LLMs) love