Skip to content

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

Class: Message

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

This object represents a message.

Extended by

Constructors

Constructor

new Message(payload): Message

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

Parameters

ParameterType
payloadTelegramMessage

Returns

Message

Properties

PropertyTypeDefined in
payloadTelegramMessagecontexts/index.d.ts:2909

Accessors

[toStringTag]

Get Signature

get [toStringTag](): string

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

MDN

Returns

string


animation

Get Signature

get animation(): AnimationAttachment

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

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:2999

Message is an audio file, information about the file

Returns

AudioAttachment


authorSignature

Get Signature

get authorSignature(): string

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

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:2937

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:3018

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:3023

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:3094

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:2939

Conversation the message belongs to

Returns

Chat


chatBackgroundSet

Get Signature

get chatBackgroundSet(): ChatBackground

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

Service message: chat background set

Returns

ChatBackground


chatBoostAdded

Get Signature

get chatBoostAdded(): ChatBoostAdded

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

Service message: chat boost added

Returns

ChatBoostAdded


chatOwnerChanged

Get Signature

get chatOwnerChanged(): ChatOwnerChanged

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

Service message: chat owner has changed

Returns

ChatOwnerChanged


chatOwnerLeft

Get Signature

get chatOwnerLeft(): ChatOwnerLeft

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

Service message: chat owner has left

Returns

ChatOwnerLeft


chatShared

Get Signature

get chatShared(): ChatShared

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

Service message: a chat was shared with the bot

Returns

ChatShared


checklist

Get Signature

get checklist(): Checklist

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

Returns

Checklist


checklistTasksAdded

Get Signature

get checklistTasksAdded(): ChecklistTasksAdded

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

Service message: checklist tasks added

Returns

ChecklistTasksAdded


checklistTasksDone

Get Signature

get checklistTasksDone(): ChecklistTasksDone

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

Service message: checklist tasks done

Returns

ChecklistTasksDone


connectedWebsite

Get Signature

get connectedWebsite(): string

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

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:3031

Message is a shared contact, information about the contact

Returns

Contact


createdAt

Get Signature

get createdAt(): number

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

Date the message was sent in Unix time

Returns

number


deleteChatPhoto

Get Signature

get deleteChatPhoto(): true

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

Service message: the chat photo was deleted

Returns

true


dice

Get Signature

get dice(): Dice

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

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:3152

Service message: direct message price changed

Returns

DirectMessagePriceChanged


directMessagesTopic

Get Signature

get directMessagesTopic(): DirectMessagesTopic

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

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:3001

Message is a general file, information about the file

Returns

DocumentAttachment


effectId

Get Signature

get effectId(): string

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

Unique identifier of the message effect added to the message

Returns

string


entities

Get Signature

get entities(): MessageEntity[]

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

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

Returns

MessageEntity[]


externalReply

Get Signature

get externalReply(): ExternalReplyInfo

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

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:3168

Service message: forum topic closed

Returns

ForumTopicClosed


forumTopicCreated

Get Signature

get forumTopicCreated(): ForumTopicCreated

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

Service message: forum topic created

Returns

ForumTopicCreated


forumTopicEdited

Get Signature

get forumTopicEdited(): ForumTopicEdited

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

Service message: forum topic edited

Returns

ForumTopicEdited


forumTopicReopened

Get Signature

get forumTopicReopened(): ForumTopicReopened

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

Service message: forum topic reopened

Returns

ForumTopicReopened


forwardOrigin

Get Signature

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

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

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:2920

Sender, empty for messages sent to channels

Returns

User


game

Get Signature

get game(): Game

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

Message is a game, information about the game

Returns

Game


generalForumTopicHidden

Get Signature

get generalForumTopicHidden(): GeneralForumTopicHidden

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

Service message: the 'General' forum topic hidden

Returns

GeneralForumTopicHidden


generalForumTopicUnhidden

Get Signature

get generalForumTopicUnhidden(): GeneralForumTopicUnhidden

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

Service message: the 'General' forum topic unhidden

Returns

GeneralForumTopicUnhidden


gift

Get Signature

get gift(): GiftInfo

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

Service message: a gift was sent to the chat

Returns

GiftInfo


giftUpgradeSent

Get Signature

get giftUpgradeSent(): GiftInfo

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

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:3176

The message is a scheduled giveaway message

Returns

Giveaway


giveawayCompleted

Get Signature

get giveawayCompleted(): GiveawayCompleted

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

Service message: a giveaway without public winners was completed

Returns

GiveawayCompleted


giveawayCreated

Get Signature

get giveawayCreated(): GiveawayCreated

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

Service message: a scheduled giveaway was created

Returns

GiveawayCreated


giveawayWinners

Get Signature

get giveawayWinners(): GiveawayWinners

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

A giveaway with public winners was completed

Returns

GiveawayWinners


groupChatCreated

Get Signature

get groupChatCreated(): true

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

Service message: the group has been created

Returns

true


id

Get Signature

get id(): number

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

Unique message identifier inside this chat

Returns

number


invoice

Get Signature

get invoice(): Invoice

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

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:3065

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:2988

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

Returns

LinkPreviewOptions


location

Get Signature

get location(): Location

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

Message is a shared location, information about the location

Returns

Location


mediaGroupId

Get Signature

get mediaGroupId(): string

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

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:3087

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

Returns

MessageAutoDeleteTimerChanged


migrateFromChatId

Get Signature

get migrateFromChatId(): number

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

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:3102

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:3060

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:3073

A chat photo was change to this value

Returns

PhotoSize[]


newChatTitle

Get Signature

get newChatTitle(): string

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

A chat title was changed to this value

Returns

string


paidStarCount

Get Signature

get paidStarCount(): number

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

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:3055

Telegram Passport data

Returns

PassportData


photo

Get Signature

get photo(): PhotoSize[]

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

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:3116

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:3037

Message is a native poll, information about the poll

Returns

Poll


proximityAlertTriggered

Get Signature

get proximityAlertTriggered(): ProximityAlertTriggered

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

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:2956

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

Returns

TextQuote


replyMarkup

Get Signature

get replyMarkup(): InlineKeyboardMarkup

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

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:2947

For replies, the original message

Returns

Omit<Message, "replyMessage">


replyStory

Get Signature

get replyStory(): Story

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

For replies to a story, the original story

Returns

Story


replyToChecklistTaskId

Get Signature

get replyToChecklistTaskId(): number

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

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

Returns

number


senderBoostCount

Get Signature

get senderBoostCount(): number

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

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:2931

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:2927

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:2933

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:3005

Message is a sticker, information about the sticker

Returns

StickerAttachment


story

Get Signature

get story(): StoryAttachment

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

Message is a forwarded story

Returns

StoryAttachment


successfulPayment

Get Signature

get successfulPayment(): SuccessfulPayment

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

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:3156

Service message: approval of a suggested post has failed

Returns

SuggestedPostApprovalFailed


suggestedPostApproved

Get Signature

get suggestedPostApproved(): SuggestedPostApproved

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

Service message: a suggested post was approved

Returns

SuggestedPostApproved


suggestedPostDeclined

Get Signature

get suggestedPostDeclined(): SuggestedPostDeclined

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

Service message: a suggested post was declined

Returns

SuggestedPostDeclined


suggestedPostInfo

Get Signature

get suggestedPostInfo(): SuggestedPostInfo

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

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:3160

Service message: payment for a suggested post was received

Returns

SuggestedPostPaid


suggestedPostRefunded

Get Signature

get suggestedPostRefunded(): SuggestedPostRefunded

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

Service message: payment for a suggested post was refunded

Returns

SuggestedPostRefunded


supergroupChatCreated

Get Signature

get supergroupChatCreated(): true

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

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:2981

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

Returns

string


threadId

Get Signature

get threadId(): number

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

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:3133

Service message: a unique gift was sent to the chat

Returns

UniqueGiftInfo


updatedAt

Get Signature

get updatedAt(): number

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

Date the message was last edited in Unix time

Returns

number


usersShared

Get Signature

get usersShared(): UsersShared

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

Service message: a user was shared with the bot

Returns

UsersShared


venue

Get Signature

get venue(): Venue

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

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:2958

Bot through which the message was sent

Returns

User


video

Get Signature

get video(): VideoAttachment

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

Message is a video, information about the video

Returns

VideoAttachment


videoChatEnded

Get Signature

get videoChatEnded(): VideoChatEnded

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

Service message: video chat ended

Returns

VideoChatEnded


videoChatParticipantsInvited

Get Signature

get videoChatParticipantsInvited(): VideoChatParticipantsInvited

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

Service message: new participants invited to a video chat

Returns

VideoChatParticipantsInvited


videoChatScheduled

Get Signature

get videoChatScheduled(): VideoChatScheduled

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

Service message: video chat scheduled

Returns

VideoChatScheduled


videoChatStarted

Get Signature

get videoChatStarted(): VideoChatStarted

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

Service message: video chat started

Returns

VideoChatStarted


videoNote

Get Signature

get videoNote(): VideoNoteAttachment

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

Message is a video note, information about the video message

Returns

VideoNoteAttachment


voice

Get Signature

get voice(): VoiceAttachment

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

Message is a voice message, information about the file

Returns

VoiceAttachment


webAppData

Get Signature

get webAppData(): WebAppData

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

Service message: data sent by a Web App

Returns

WebAppData


writeAccessAllowed

Get Signature

get writeAccessAllowed(): WriteAccessAllowed

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

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:3029

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

Returns

true


hasProtectedContent()

hasProtectedContent(): true

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

true, if the message can't be forwarded

Returns

true


isAutomaticForward()

isAutomaticForward(): true

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

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:2964

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:2966

Optional. True, if the message is a paid post

Returns

true


isShowCaptionAboveMedia()

isShowCaptionAboveMedia(): boolean

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

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

Returns

boolean


isTopicMessage()

isTopicMessage(): boolean

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

true, if the message is sent to a forum topic

Returns

boolean