Skip to main content

Message

This object represents a message.

📝 Schema

FieldTypeDescription
message_idintUnique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent
fromUserOptional. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats
dateintDate the message was sent in Unix time. It is always a positive number, representing a valid date.
chatChatChat the message belongs to
forward_fromUserOptional. For forwarded messages, sender of the original message.
forward_from_chatChatOptional. For messages forwarded from a channel, information about the original channel.
forward_from_message_idintOptional. For forwarded channel posts, identifier of the original message in the channel.
forward_dateintOptional. For forwarded messages, date the original message was sent in Unix time.
reply_to_messageMessageOptional. For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
edite_dateintOptional. Date the message was last edited in Unix time.
textstringOptional. For text messages, the actual UTF-8 text of the message
animationAnimationOptional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
audioAudioOptional. Message is an audio file, information about the file
documentDocumentOptional. Message is a general file, information about the file
photoArray of PhotoSizeOptional. Message is a photo, available sizes of the photo
stickerStickerOptional. Message is a sticker, information about the sticker
videoVideoOptional. Message is a video, information about the video
voiceVoiceOptional. Message is a voice message, information about the file
captionstringOptional. Caption for the animation, audio, document, photo, video or voice
contactContactOptional. Message is a shared contact, information about the contact
locationLocationOptional. Message is a shared location, information about the location
new_chat_membersArray of UserOptional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
left_chat_memberUserOptional. A member was removed from the group, information about them (this member may be the bot itself)
invoiceInvoiceOptional. Message is an invoice for a payment, information about the invoice. More about payments »
successful_paymentSuccessfulPaymentOptional. Message is a service message about a successful payment, information about the payment. More about payments »
reply_markupInlineKeyboardMarkupOptional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.

⚙️ Get methods

getMessageId()

Retrieves the unique identifier of the message.

$messageMessageId = $messageObject->getMessageId();

getFrom()

Retrieves the sender of the message.

$messageFrom = $messageObject->getFrom();

getDate()

Retrieves the date the message was sent in Unix time.

$messageDate = $messageObject->getDate();

getChat()

Retrieves the chat the message belongs to.

$messageChat = $messageObject->getChat();

getForwardFrom()

Retrieves the sender of the original message, if this is a forwarded message.

$messageForwardFrom = $messageObject->getForwardFrom();

getForwardFromChat()

Retrieves the channel from which the message was forwarded, if applicable.

$messageForwardFromChat = $messageObject->getForwardFromChat();

getForwardFromMessageId()

Retrieves the original message ID in the channel for forwarded messages.

$messageForwardFromMessageId = $messageObject->getForwardFromMessageId();

getForwardDate()

Retrieves the Unix timestamp when the original message was sent.

$messageForwardDate = $messageObject->getForwardDate();

getReplyToMessage()

Retrieves the original message that this message is replying to.

$messageReplyTo = $messageObject->getReplyToMessage();

getEditDate()

Retrieves the last edit time of the message in Unix time.

$messageEditDate = $messageObject->getEditDate();

getText()

Retrieves the text content of the message, if available.

$messageText = $messageObject->getText();

getAnimation()

Retrieves details of the animation, if the message contains one.

$messageAnimation = $messageObject->getAnimation();

getAudio()

Retrieves details of the audio, if the message contains one.

$messageAudio = $messageObject->getAudio();

getDocument()

Retrieves details of the document, if the message contains one.

$messageDocument = $messageObject->getDocument();

getPhoto()

Retrieves the array of photo sizes, if the message contains a photo.

$messagePhoto = $messageObject->getPhoto();

getSticker()

Retrieves details of the sticker, if the message contains one.

$messageSticker = $messageObject->getSticker();

getVideo()

Retrieves details of the video, if the message contains one.

$messageVideo = $messageObject->getVideo();

getVoice()

Retrieves details of the voice message, if the message contains one.

$messageVoice = $messageObject->getVoice();

getCaption()

Retrieves the caption of the media, if available.

$messageCaption = $messageObject->getCaption();

getContact()

Retrieves details of the contact, if the message contains one.

$messageContact = $messageObject->getContact();

getLocation()

Retrieves details of the location, if the message contains one.

$messageLocation = $messageObject->getLocation();

getNewChatMembers()

Retrieves an array of new chat members added to the group or supergroup.

$newChatMembers = $messageObject->getNewChatMembers();

getLeftChatMember()

Retrieves details of the member who left or was removed from the chat.

$leftChatMember = $messageObject->getLeftChatMember();

getInvoice()

Retrieves details of the invoice, if the message contains one.

$messageInvoice = $messageObject->getInvoice();

getSuccessfulPayment()

Retrieves details of a successful payment message.

$successfulPayment = $messageObject->getSuccessfulPayment();

getReplyMarkup()

Retrieves the inline keyboard attached to the message, if available.

$replyMarkup = $messageObject->getReplyMarkup();

➕ More

tip

For further information, refer to the official Bale documentation for more details.