Rich Message
How it works
Rich messages support advanced structured formatting options like headings, lists, tables, media, block quotations, collapsible blocks, footnotes, and formulas. Telegram clients will render them accordingly.
NoteBy Default, the Rich Message content will be sent in HTML format.
For the automatic Entity detection info or Rich Message limits visit https://core.telegram.org/bots/api#rich-messages
Attachments
Rich Message can be sent through Telegraph ->richMessage() method:
Telegraph::richMessage('<u>Rich Message</u>') //Default HTML format ->asMarkdown() //Rich Message can be formatted as Markdown ->businessConnectionId($id) //Unique identifier of the business connection ->messageThreadId($id) //Unique identifier for the target message thread (topic) of a forum ->directMessageTopicId($id) //Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat ->disableNotification() //Sends the message silently ->protectContent() //Protects the contents of the sent message from forwarding and saving ->allowPaidBroadcast() //Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance ->messageEffectId($id) //Unique identifier of the message effect to be added to the message; for private chats only ->suggestedPostParameters([...]) //A JSON-serialized object containing the parameters of the suggested post to send; Visit https://core.telegram.org/bots/api#suggestedpostparameters ->send();
Incoming Data
RichMessage
->blocks()Content of the message , array ofRichBlock->isRtl()Optional. True, if the rich message must be shown right-to-left
RichBlock
This object represents a block in a rich formatted message. Currently, it can be any of the following types:
RichBlockParagraph
A text paragraph, corresponding to the HTML tag <p>.
->type()Type of the block, always “paragraph”->text()Text of the block, instance ofRichText
RichBlockSectionHeading
A section heading, corresponding to the HTML tags <h1>, <h2>, <h3>, <h4>, <h5>, or <h6>.
->type()Type of the block, always “heading”->text()Text of the block, instance ofRichText->size()Relative size of the text font; 1-6, 1 is the largest, 6 is the smallest
RichBlockPreformatted
A preformatted text block, corresponding to the nested HTML tags <pre> and <code>.
->type()Type of the block, always “pre”->text()Text of the block, instance ofRichText->language()Optional. The programming language of the text
RichBlockFooter
A footer, corresponding to the HTML tag <footer>.
->type()Type of the block, always “footer”->text()Text of the block, instance ofRichText
RichBlockDivider
A divider, corresponding to the HTML tag <hr/>.
->type()Type of the block, always “divider”
RichBlockMathematicalExpression
A block with a mathematical expression in LaTeX format, corresponding to the custom HTML tag <tg-math-block>.
->type()Type of the block, always “mathematical_expression”->expression()The mathematical expression in LaTeX format
RichBlockAnchor
A block with an anchor, corresponding to the HTML tag <a> with the attribute name.
->type()Type of the block, always “anchor”->name()The name of the anchor
RichBlockList
A list of blocks, corresponding to the HTML tag <ul> or <ol> with multiple nested tags <li>.
->type()Type of the block, always “list”->items()Items of the list , array ofRichBlockListItem
RichBlockBlockQuotation
A block quotation, corresponding to the HTML tag <blockquote>.
->type()Type of the block, always “blockquote”->blocks()Content of the block , array ofRichBlock->credit()Optional. Credit of the block, instance ofRichText
RichBlockPullQuotation
A quotation with centered text, loosely corresponding to the HTML tag <aside>.
->type()Type of the block, always “pullquote”->text()Text of the block, instance ofRichText->credit()Optional. Credit of the block, instance ofRichText
RichBlockCollage
A collage, corresponding to the custom HTML tag <tg-collage>.
->type()Type of the block, always “collage”->blocks()Elements of the collage, array ofRichBlock->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockSlideshow
A slideshow, corresponding to the custom HTML tag <tg-slideshow>.
->type()Type of the block, always “slideshow”->blocks()Elements of the slideshow, array ofRichBlock->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockTable
A table, corresponding to the HTML tag <table>.
->type()Type of the block, always “table”->cells()Cells of the table, array of array ofRichBlockTableCell->isBordered()Optional. True, if the table has borders->isStriped()Optional. True, if the table is striped->caption()Optional. Caption of the table, instance ofRichText
RichBlockDetails
An expandable block for details disclosure, corresponding to the HTML tag <details>.
->type()Type of the block, always “details”->summary()Always shown summary of the block, instance ofRichText->blocks()Content of the block, array ofRichBlock->isOpen()Optional. True, if the content of the block is visible by default
RichBlockMap
A block with a map, corresponding to the custom HTML tag <tg-map>.
->type()Type of the block, always “map”->location()Location of the center of the map, instance ofLocation->zoom()Map zoom level; 13-20->width()Expected width of the map->height()Expected height of the map->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockAnimation
A block with an animation, corresponding to the HTML tag <video>.
->type()Type of the block, always “animation”->animation()The animation, instance ofAnimation->hasSpoiler()Optional. True, if the media preview is covered by a spoiler animation->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockAudio
A block with a music file, corresponding to the HTML tag <audio>.
->type()Type of the block, always “audio”->audio()The audio, instance ofAudio->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockPhoto
A block with a photo, corresponding to the HTML tag <img>.
->type()Type of the block, always “photo”->photos()Available sizes of the photo, array ofPhoto->hasSpoiler()Optional. True, if the media preview is covered by a spoiler animation->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockVideo
A block with a video, corresponding to the HTML tag <video>.
->type()Type of the block, always “video”->video()The video, instance ofVideo->hasSpoiler()Optional. True, if the media preview is covered by a spoiler animation->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockVoiceNote
A block with a voice note, corresponding to the HTML tag <audio>.
->type()Type of the block, always “voice_note”->voiceNote()The voice note, instance ofVoice->caption()Optional. Caption of the block, instance ofRichBlockCaption
RichBlockThinking
A block with a “Thinking…” placeholder, corresponding to the custom HTML tag <tg-thinking>.
The block may be used only in sendRichMessageDraft, therefore it can't be received in messages.
See https://t.me/addemoji/AIActions for examples of custom emoji, which are recommended for usage in the block.
->type()Type of the block, always “thinking”->text()Text of the block. See https://t.me/addemoji/AIActions for examples of custom emoji, which are recommended for usage in the block.Instance ofRichText
RichText
This object represents a rich formatted text. Currently, it can be a Collection of RichTextItem or any of the following types:
RichTextString
This object represents a simple string. The type is NULL
->type()Type of the rich text->text()The text
RichTextBold
->type()Type of the rich text, always “bold”->text()The text , instance ofRichText
RichTextItalic
->type()Type of the rich text, always “italic”->text()The text , instance ofRichText
RichTextUnderline
->type()Type of the rich text, always “underline”->text()The text , instance ofRichText
RichTextStrikethrough
->type()Type of the rich text, always “strikethrough”->text()The text , instance ofRichText
RichTextSpoiler
->type()Type of the rich text, always “spoiler”->text()The text , instance ofRichText
RichTextDateTime
->type()Type of the rich text, always “date_time”->text()The text , instance ofRichText->unixTime()The Unix time associated with the entity->dateTimeFormat()The string that defines the formatting of the date and time. See https://core.telegram.org/bots/api#date-time-entity-formatting
RichTextTextMention
->type()Type of the rich text, always “text_mention”->text()The text , instance ofRichText->user()The mentionedUser
RichTextSubscript
->type()Type of the rich text, always “subscript”->text()The text , instance ofRichText
RichTextSuperscript
->type()Type of the rich text, always “superscript”->text()The text , instance ofRichText
RichTextMarked
->type()Type of the rich text, always “marked”->text()The text , instance ofRichText
RichTextCode
->type()Type of the rich text, always “code”->text()The text , instance ofRichText
RichTextCustomEmoji
->type()Type of the rich text, always “custom_emoji”->customEmojiId()Unique identifier of the custom emoji->alternativeText()Alternative emoji for the custom emoji
RichTextMathematicalExpression
->type()Type of the rich text, always “mathematical_expression”->expression()The expression in LaTeX format
RichTextUrl
->type()Type of the rich text, always “url”->text()The text , instance ofRichText->url()URL of the link
RichTextEmailAddress
->type()Type of the rich text, always “email_address”->text()The text , instance ofRichText->emailAddress()The email address
RichTextPhoneNumber
->type()Type of the rich text, always “phone_number”->text()The text , instance ofRichText->phoneNumber()The phone number
RichTextBankCardNumber
->type()Type of the rich text, always “bank_card_number”->text()The text , instance ofRichText->bankCardNumber()The bank card number
RichTextMention
->type()Type of the rich text, always “mention”->text()The text , instance ofRichText->username()The username
RichTextHashtag
->type()Type of the rich text, always “hashtag”->text()The text , instance ofRichText->hashtag()The hashtag
RichTextCashtag
->type()Type of the rich text, always “cashtag”->text()The text , instance ofRichText->cashtag()The cashtag
RichTextBotCommand
->type()Type of the rich text, always “bot_command”->text()The text , instance ofRichText->botCommand()The bot command
RichTextAnchor
->type()Type of the rich text, always “anchor”->name()The name of the anchor
RichTextAnchorLink
->type()Type of the rich text, always “anchor_link”->text()The text , instance ofRichText->anchorName()The name of the anchor. If the name is empty, then the link brings back to the top of the message.
RichTextReference
->type()Type of the rich text, always “reference”->text()The text , instance ofRichText->name()The name of the reference
RichTextReferenceLink
->type()Type of the rich text, always “reference_link”->text()The text , instance ofRichText->referenceName()The name of the reference
RichBlock Elements
RichBlockCaption
Caption of a rich formatted block.
->text()Block caption, instance ofRichText->credit()Optional. Block credit , instance ofRichText
RichBlockTableCell
Cell in a table.
->text()Optional. Text in the cell. If omitted, then the cell is invisible. Instance ofRichText->isHeader()Optional. True, if the cell is a header cell->colspan()Optional. The number of columns the cell spans if it is bigger than 1->rowspan()Optional. The number of rows the cell spans if it is bigger than 1->align()Horizontal cell content alignment. Currently, must be one of “left”, “center”, or “right”.->valign()Vertical cell content alignment. Currently, must be one of “top”, “middle”, or “bottom”.
RichBlockListItem
An item of a list.
->label()Label of the item->blocks()The content of the item, array ofRichBlock->hasCheckbox()Optional. True, if the item has a checkbox->isChecked()Optional. True, if the item has a checked checkbox->value()Optional. For ordered lists, the numeric value of the item label->type()Optional. For ordered lists, the type of the item label; must be one of “a” for lowercase letters, “A” for uppercase letters, “i” for lowercase Roman numerals, “I” for uppercase Roman numerals, or “1” for decimal numbers