Skip to content

GramIO API Reference / @gramio/contexts/dist / Message

Class: Message

Defined in: contexts/index.d.ts:3305

This object represents a message.

Extended by

Constructors

Constructor

new Message(payload): Message

Defined in: contexts/index.d.ts:3307

Parameters

ParameterType
payloadTelegramMessage

Returns

Message

Properties

PropertyTypeDefined in
payloadTelegramMessagecontexts/index.d.ts:3306

Accessors

[toStringTag]

Get Signature

get [toStringTag](): string

Defined in: contexts/index.d.ts:3309

MDN

Returns

string


animation

Get Signature

get animation(): AnimationAttachment

Defined in: contexts/index.d.ts:3410

Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set

Returns

AnimationAttachment


audio

Get Signature

get audio(): AudioAttachment

Defined in: contexts/index.d.ts:3412

Message is an audio file, information about the file

Returns

AudioAttachment


authorSignature

Get Signature

get authorSignature(): string

Defined in: contexts/index.d.ts:3381

Signature of the post author for messages in channels, or the custom title of an anonymous group administrator

Returns

string


businessConnectionId

Get Signature

get businessConnectionId(): string

Defined in: contexts/index.d.ts:3339

Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.

Returns

string


caption

Get Signature

get caption(): string

Defined in: contexts/index.d.ts:3436

Caption for the animation, audio, document, photo, video or voice, 0-1024 characters

Returns

string


captionEntities

Get Signature

get captionEntities(): MessageEntity[]

Defined in: contexts/index.d.ts:3441

For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption

Returns

MessageEntity[]


channelChatCreated

Get Signature

get channelChatCreated(): true

Defined in: contexts/index.d.ts:3512

Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in replyMessage if someone replies to a very first message in a channel.

Returns

true


chat

Get Signature

get chat(): Chat

Defined in: contexts/index.d.ts:3341

Conversation the message belongs to

Returns

Chat


chatBackgroundSet

Get Signature

get chatBackgroundSet(): ChatBackground

Defined in: contexts/index.d.ts:3563

Service message: chat background set

Returns

ChatBackground


chatBoostAdded

Get Signature

get chatBoostAdded(): ChatBoostAdded

Defined in: contexts/index.d.ts:3561

Service message: chat boost added

Returns

ChatBoostAdded


chatOwnerChanged

Get Signature

get chatOwnerChanged(): ChatOwnerChanged

Defined in: contexts/index.d.ts:3487

Service message: chat owner has changed

Returns

ChatOwnerChanged


chatOwnerLeft

Get Signature

get chatOwnerLeft(): ChatOwnerLeft

Defined in: contexts/index.d.ts:3485

Service message: chat owner has left

Returns

ChatOwnerLeft


chatShared

Get Signature

get chatShared(): ChatShared

Defined in: contexts/index.d.ts:3545

Service message: a chat was shared with the bot

Returns

ChatShared


checklist

Get Signature

get checklist(): Checklist

Defined in: contexts/index.d.ts:3356

Returns

Checklist


checklistTasksAdded

Get Signature

get checklistTasksAdded(): ChecklistTasksAdded

Defined in: contexts/index.d.ts:3568

Service message: checklist tasks added

Returns

ChecklistTasksAdded


checklistTasksDone

Get Signature

get checklistTasksDone(): ChecklistTasksDone

Defined in: contexts/index.d.ts:3565

Service message: checklist tasks done

Returns

ChecklistTasksDone


communityChatAdded

Get Signature

get communityChatAdded(): CommunityChatAdded

Defined in: contexts/index.d.ts:3625

Service message: a chat was added to a community

Returns

CommunityChatAdded


communityChatJoined

Get Signature

get communityChatJoined(): CommunityChatJoined

Defined in: contexts/index.d.ts:3627

Service message: a chat joined a community

Returns

CommunityChatJoined


communityChatRemoved

Get Signature

get communityChatRemoved(): CommunityChatRemoved

Defined in: contexts/index.d.ts:3629

Service message: a chat was removed from a community

Returns

CommunityChatRemoved


connectedWebsite

Get Signature

get connectedWebsite(): string

Defined in: contexts/index.d.ts:3471

The domain name of the website on which the user has logged in.

Returns

string


contact

Get Signature

get contact(): Contact

Defined in: contexts/index.d.ts:3449

Message is a shared contact, information about the contact

Returns

Contact


createdAt

Get Signature

get createdAt(): number

Defined in: contexts/index.d.ts:3332

Date the message was sent in Unix time

Returns

number


deleteChatPhoto

Get Signature

get deleteChatPhoto(): true

Defined in: contexts/index.d.ts:3493

Service message: the chat photo was deleted

Returns

true


dice

Get Signature

get dice(): Dice

Defined in: contexts/index.d.ts:3451

Message is a dice with random value from 1 to 6

Returns

Dice


directMessagePriceChanged

Get Signature

get directMessagePriceChanged(): DirectMessagePriceChanged

Defined in: contexts/index.d.ts:3570

Service message: direct message price changed

Returns

DirectMessagePriceChanged


directMessagesTopic

Get Signature

get directMessagesTopic(): DirectMessagesTopic

Defined in: contexts/index.d.ts:3315

Optional. Information about the direct messages chat topic that contains the message

Returns

DirectMessagesTopic


document

Get Signature

get document(): DocumentAttachment

Defined in: contexts/index.d.ts:3414

Message is a general file, information about the file

Returns

DocumentAttachment


effectId

Get Signature

get effectId(): string

Defined in: contexts/index.d.ts:3403

Unique identifier of the message effect added to the message

Returns

string


entities

Get Signature

get entities(): MessageEntity[]

Defined in: contexts/index.d.ts:3397

For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text

Returns

MessageEntity[]


ephemeralMessageId

Get Signature

get ephemeralMessageId(): number

Defined in: contexts/index.d.ts:3623

Unique message identifier of this ephemeral message inside the chat. Use it with editEphemeralMessage* / deleteEphemeralMessage and as ReplyParameters.ephemeral_message_id. Present only for ephemeral messages.

Returns

number


externalReply

Get Signature

get externalReply(): ExternalReplyInfo

Defined in: contexts/index.d.ts:3358

Information about the message that is being replied to, which may come from another chat or forum topic

Returns

ExternalReplyInfo


forumTopicClosed

Get Signature

get forumTopicClosed(): ForumTopicClosed

Defined in: contexts/index.d.ts:3586

Service message: forum topic closed

Returns

ForumTopicClosed


forumTopicCreated

Get Signature

get forumTopicCreated(): ForumTopicCreated

Defined in: contexts/index.d.ts:3582

Service message: forum topic created

Returns

ForumTopicCreated


forumTopicEdited

Get Signature

get forumTopicEdited(): ForumTopicEdited

Defined in: contexts/index.d.ts:3584

Service message: forum topic edited

Returns

ForumTopicEdited


forumTopicReopened

Get Signature

get forumTopicReopened(): ForumTopicReopened

Defined in: contexts/index.d.ts:3588

Service message: forum topic reopened

Returns

ForumTopicReopened


forwardOrigin

Get Signature

get forwardOrigin(): MessageOriginUser | MessageOriginChat | MessageOriginChannel | MessageOriginHiddenUser

Defined in: contexts/index.d.ts:3343

Information about the original message for forwarded messages

Returns

MessageOriginUser | MessageOriginChat | MessageOriginChannel | MessageOriginHiddenUser


from

Get Signature

get from(): User

Defined in: contexts/index.d.ts:3317

Sender, empty for messages sent to channels

Returns

User


game

Get Signature

get game(): Game

Defined in: contexts/index.d.ts:3453

Message is a game, information about the game

Returns

Game


generalForumTopicHidden

Get Signature

get generalForumTopicHidden(): GeneralForumTopicHidden

Defined in: contexts/index.d.ts:3590

Service message: the 'General' forum topic hidden

Returns

GeneralForumTopicHidden


generalForumTopicUnhidden

Get Signature

get generalForumTopicUnhidden(): GeneralForumTopicUnhidden

Defined in: contexts/index.d.ts:3592

Service message: the 'General' forum topic unhidden

Returns

GeneralForumTopicUnhidden


gift

Get Signature

get gift(): GiftInfo

Defined in: contexts/index.d.ts:3547

Service message: a gift was sent to the chat

Returns

GiftInfo


giftUpgradeSent

Get Signature

get giftUpgradeSent(): GiftInfo

Defined in: contexts/index.d.ts:3549

Service message: upgrade of a gift was purchased after the gift was sent

Returns

GiftInfo


giveaway

Get Signature

get giveaway(): Giveaway

Defined in: contexts/index.d.ts:3594

The message is a scheduled giveaway message

Returns

Giveaway


giveawayCompleted

Get Signature

get giveawayCompleted(): GiveawayCompleted

Defined in: contexts/index.d.ts:3598

Service message: a giveaway without public winners was completed

Returns

GiveawayCompleted


giveawayCreated

Get Signature

get giveawayCreated(): GiveawayCreated

Defined in: contexts/index.d.ts:3596

Service message: a scheduled giveaway was created

Returns

GiveawayCreated


giveawayWinners

Get Signature

get giveawayWinners(): GiveawayWinners

Defined in: contexts/index.d.ts:3600

A giveaway with public winners was completed

Returns

GiveawayWinners


groupChatCreated

Get Signature

get groupChatCreated(): true

Defined in: contexts/index.d.ts:3495

Service message: the group has been created

Returns

true


guestBotCallerChat

Get Signature

get guestBotCallerChat(): Chat

Defined in: contexts/index.d.ts:3366

Optional. For a message sent by a guest bot, this is the chat whose original message triggered the bot's response

Returns

Chat


guestBotCallerUser

Get Signature

get guestBotCallerUser(): User

Defined in: contexts/index.d.ts:3364

Optional. For a message sent by a guest bot, this is the user whose original message triggered the bot's response

Returns

User


guestQueryId

Get Signature

get guestQueryId(): string

Defined in: contexts/index.d.ts:3337

Optional. The unique identifier for the guest query. Use this identifier with the method answerGuestQuery to send a response message. If non-empty, the message belongs to the chat where the guest bot was summoned, which may not coincide with other existing bot chats sharing the same identifier.

Returns

string


id

Get Signature

get id(): number

Defined in: contexts/index.d.ts:3311

Unique message identifier inside this chat

Returns

number


invoice

Get Signature

get invoice(): Invoice

Defined in: contexts/index.d.ts:3536

Message is an invoice for a payment, information about the invoice

Returns

Invoice


leftChatMember

Get Signature

get leftChatMember(): User

Defined in: contexts/index.d.ts:3483

A member was removed from the group, information about them (this member may be the bot itself)

Returns

User


linkPreviewOptions

Get Signature

get linkPreviewOptions(): LinkPreviewOptions

Defined in: contexts/index.d.ts:3399

Options used for link preview generation for the message, if it is a text message and link preview options were changed

Returns

LinkPreviewOptions


livePhoto

Get Signature

get livePhoto(): LivePhotoAttachment

Defined in: contexts/index.d.ts:3419

Message is a live photo, information about the live photo. For backward compatibility, when this field is set, the photo field will also be set

Returns

LivePhotoAttachment


location

Get Signature

get location(): Location

Defined in: contexts/index.d.ts:3463

Message is a shared location, information about the location

Returns

Location


managedBotCreated

Get Signature

get managedBotCreated(): ManagedBotCreated

Defined in: contexts/index.d.ts:3612

Service message: user created a bot that will be managed by the current bot

Returns

ManagedBotCreated


mediaGroupId

Get Signature

get mediaGroupId(): string

Defined in: contexts/index.d.ts:3376

The unique identifier of a media message group this message belongs to

Returns

string


messageAutoDeleteTimerChanged

Get Signature

get messageAutoDeleteTimerChanged(): MessageAutoDeleteTimerChanged

Defined in: contexts/index.d.ts:3505

Service message: auto-delete timer settings changed in the chat

Returns

MessageAutoDeleteTimerChanged


migrateFromChatId

Get Signature

get migrateFromChatId(): number

Defined in: contexts/index.d.ts:3528

The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.

Returns

number


migrateToChatId

Get Signature

get migrateToChatId(): number

Defined in: contexts/index.d.ts:3520

The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.

Returns

number


newChatMembers

Get Signature

get newChatMembers(): User[]

Defined in: contexts/index.d.ts:3478

New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)

Returns

User[]


newChatPhoto

Get Signature

get newChatPhoto(): PhotoSize[]

Defined in: contexts/index.d.ts:3491

A chat photo was change to this value

Returns

PhotoSize[]


newChatTitle

Get Signature

get newChatTitle(): string

Defined in: contexts/index.d.ts:3489

A chat title was changed to this value

Returns

string


paidStarCount

Get Signature

get paidStarCount(): number

Defined in: contexts/index.d.ts:3385

Optional. The number of Telegram Stars that were paid by the sender of the message to send it

Returns

number


passportData

Get Signature

get passportData(): PassportData

Defined in: contexts/index.d.ts:3473

Telegram Passport data

Returns

PassportData


photo

Get Signature

get photo(): PhotoSize[]

Defined in: contexts/index.d.ts:3421

Message is a photo, available sizes of the photo

Returns

PhotoSize[]


pinnedMessage

Get Signature

get pinnedMessage(): Omit<Message, "replyMessage"> | InaccessibleMessage

Defined in: contexts/index.d.ts:3534

Specified message was pinned. Note that the Message object in this field will not contain further replyMessage fields even if it is itself a reply.

Returns

Omit<Message, "replyMessage"> | InaccessibleMessage


poll

Get Signature

get poll(): Poll

Defined in: contexts/index.d.ts:3455

Message is a native poll, information about the poll

Returns

Poll


pollOptionAdded

Get Signature

get pollOptionAdded(): PollOptionAdded

Defined in: contexts/index.d.ts:3631

Service message: answer option was added to a poll

Returns

PollOptionAdded


pollOptionDeleted

Get Signature

get pollOptionDeleted(): PollOptionDeleted

Defined in: contexts/index.d.ts:3633

Service message: answer option was deleted from a poll

Returns

PollOptionDeleted


proximityAlertTriggered

Get Signature

get proximityAlertTriggered(): ProximityAlertTriggered

Defined in: contexts/index.d.ts:3557

Service message. A user in the chat triggered another user's proximity alert while sharing Live Location.

Returns

ProximityAlertTriggered


quote

Get Signature

get quote(): TextQuote

Defined in: contexts/index.d.ts:3360

For replies that quote part of the original message, the quoted part of the message

Returns

TextQuote


receiverUser

Get Signature

get receiverUser(): User

Defined in: contexts/index.d.ts:3617

The only user who can see this ephemeral message, along with the bot. Present only for ephemeral messages.

Returns

User


replyMarkup

Get Signature

get replyMarkup(): InlineKeyboardMarkup

Defined in: contexts/index.d.ts:3469

Inline keyboard attached to the message.

login_url buttons are represented as ordinary url buttons.

Returns

InlineKeyboardMarkup


replyMessage

Get Signature

get replyMessage(): Omit<Message, "replyMessage">

Defined in: contexts/index.d.ts:3349

For replies, the original message

Returns

Omit<Message, "replyMessage">


replyStory

Get Signature

get replyStory(): Story

Defined in: contexts/index.d.ts:3351

For replies to a story, the original story

Returns

Story


replyToChecklistTaskId

Get Signature

get replyToChecklistTaskId(): number

Defined in: contexts/index.d.ts:3353

Optional. Identifier of the specific checklist task that is being replied to

Returns

number


replyToPollOptionId

Get Signature

get replyToPollOptionId(): string

Defined in: contexts/index.d.ts:3355

Optional. Persistent identifier of the specific poll option that is being replied to

Returns

string


richMessage

Get Signature

get richMessage(): RichMessage

Defined in: contexts/index.d.ts:3405

Message is a rich formatted message

Returns

RichMessage


senderBoostCount

Get Signature

get senderBoostCount(): number

Defined in: contexts/index.d.ts:3326

If the sender of the message boosted the chat, the number of boosts added by the user

Returns

number


senderBusinessBot

Get Signature

get senderBusinessBot(): User

Defined in: contexts/index.d.ts:3328

The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.

Returns

User


senderChat

Get Signature

get senderChat(): Chat

Defined in: contexts/index.d.ts:3324

Sender of the message, sent on behalf of a chat. The channel itself for channel messages. The supergroup itself for messages from anonymous group administrators. The linked channel for messages automatically forwarded to the discussion group

Returns

Chat


senderTag

Get Signature

get senderTag(): string

Defined in: contexts/index.d.ts:3330

Tag or custom title of the sender of the message; for supergroups only

Returns

string


sticker

Get Signature

get sticker(): StickerAttachment

Defined in: contexts/index.d.ts:3423

Message is a sticker, information about the sticker

Returns

StickerAttachment


story

Get Signature

get story(): StoryAttachment

Defined in: contexts/index.d.ts:3425

Message is a forwarded story

Returns

StoryAttachment


successfulPayment

Get Signature

get successfulPayment(): SuccessfulPayment

Defined in: contexts/index.d.ts:3541

Message is a service message about a successful payment, information about the payment.

Returns

SuccessfulPayment


suggestedPostApprovalFailed

Get Signature

get suggestedPostApprovalFailed(): SuggestedPostApprovalFailed

Defined in: contexts/index.d.ts:3574

Service message: approval of a suggested post has failed

Returns

SuggestedPostApprovalFailed


suggestedPostApproved

Get Signature

get suggestedPostApproved(): SuggestedPostApproved

Defined in: contexts/index.d.ts:3572

Service message: a suggested post was approved

Returns

SuggestedPostApproved


suggestedPostDeclined

Get Signature

get suggestedPostDeclined(): SuggestedPostDeclined

Defined in: contexts/index.d.ts:3576

Service message: a suggested post was declined

Returns

SuggestedPostDeclined


suggestedPostInfo

Get Signature

get suggestedPostInfo(): SuggestedPostInfo

Defined in: contexts/index.d.ts:3401

Optional. Information about suggested post parameters if the message is a suggested post

Returns

SuggestedPostInfo


suggestedPostPaid

Get Signature

get suggestedPostPaid(): SuggestedPostPaid

Defined in: contexts/index.d.ts:3578

Service message: payment for a suggested post was received

Returns

SuggestedPostPaid


suggestedPostRefunded

Get Signature

get suggestedPostRefunded(): SuggestedPostRefunded

Defined in: contexts/index.d.ts:3580

Service message: payment for a suggested post was refunded

Returns

SuggestedPostRefunded


supergroupChatCreated

Get Signature

get supergroupChatCreated(): true

Defined in: contexts/index.d.ts:3503

Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in replyMessage if someone replies to a very first message in a directly created supergroup.

Returns

true


text

Get Signature

get text(): string

Defined in: contexts/index.d.ts:3392

For text messages, the actual UTF-8 text of the message, 0-4096 characters.

Falls back to the flattened rich message text when the message has no plain text, so text-based handlers keep working on rich messages.

Returns

string


threadId

Get Signature

get threadId(): number

Defined in: contexts/index.d.ts:3313

Unique identifier of a message thread to which the message belongs; for supergroups only

Returns

number


uniqueGift

Get Signature

get uniqueGift(): UniqueGiftInfo

Defined in: contexts/index.d.ts:3551

Service message: a unique gift was sent to the chat

Returns

UniqueGiftInfo


updatedAt

Get Signature

get updatedAt(): number

Defined in: contexts/index.d.ts:3368

Date the message was last edited in Unix time

Returns

number


usersShared

Get Signature

get usersShared(): UsersShared

Defined in: contexts/index.d.ts:3543

Service message: a user was shared with the bot

Returns

UsersShared


venue

Get Signature

get venue(): Venue

Defined in: contexts/index.d.ts:3461

Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set

Returns

Venue


viaBot

Get Signature

get viaBot(): User

Defined in: contexts/index.d.ts:3362

Bot through which the message was sent

Returns

User


video

Get Signature

get video(): VideoAttachment

Defined in: contexts/index.d.ts:3427

Message is a video, information about the video

Returns

VideoAttachment


videoChatEnded

Get Signature

get videoChatEnded(): VideoChatEnded

Defined in: contexts/index.d.ts:3606

Service message: video chat ended

Returns

VideoChatEnded


videoChatParticipantsInvited

Get Signature

get videoChatParticipantsInvited(): VideoChatParticipantsInvited

Defined in: contexts/index.d.ts:3608

Service message: new participants invited to a video chat

Returns

VideoChatParticipantsInvited


videoChatScheduled

Get Signature

get videoChatScheduled(): VideoChatScheduled

Defined in: contexts/index.d.ts:3602

Service message: video chat scheduled

Returns

VideoChatScheduled


videoChatStarted

Get Signature

get videoChatStarted(): VideoChatStarted

Defined in: contexts/index.d.ts:3604

Service message: video chat started

Returns

VideoChatStarted


videoNote

Get Signature

get videoNote(): VideoNoteAttachment

Defined in: contexts/index.d.ts:3429

Message is a video note, information about the video message

Returns

VideoNoteAttachment


voice

Get Signature

get voice(): VoiceAttachment

Defined in: contexts/index.d.ts:3431

Message is a voice message, information about the file

Returns

VoiceAttachment


webAppData

Get Signature

get webAppData(): WebAppData

Defined in: contexts/index.d.ts:3610

Service message: data sent by a Web App

Returns

WebAppData


writeAccessAllowed

Get Signature

get writeAccessAllowed(): WriteAccessAllowed

Defined in: contexts/index.d.ts:3559

Service message: the user allowed the bot added to the attachment menu to write messages

Returns

WriteAccessAllowed

Methods

hasMediaSpoiler()

hasMediaSpoiler(): true

Defined in: contexts/index.d.ts:3447

true, if the message media is covered by a spoiler animation

Returns

true


hasProtectedContent()

hasProtectedContent(): true

Defined in: contexts/index.d.ts:3370

true, if the message can't be forwarded

Returns

true


isAutomaticForward()

isAutomaticForward(): true

Defined in: contexts/index.d.ts:3347

true, if the message is a channel post that was automatically forwarded to the connected discussion group

Returns

true


isFromOffline()

isFromOffline(): true

Defined in: contexts/index.d.ts:3372

true, True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message

Returns

true


isPaidPost()

isPaidPost(): true

Defined in: contexts/index.d.ts:3374

Optional. True, if the message is a paid post

Returns

true


isShowCaptionAboveMedia()

isShowCaptionAboveMedia(): boolean

Defined in: contexts/index.d.ts:3445

True, if the caption must be shown above the message media

Returns

boolean


isTopicMessage()

isTopicMessage(): boolean

Defined in: contexts/index.d.ts:3345

true, if the message is sent to a forum topic

Returns

boolean