<divclass="dev_page_bread_crumbs"><ulclass="breadcrumb clearfix"><li><ahref="/api">API</a></li><iclass="icon icon-breadcrumb-divider"></i><li><ahref="/api/entities">Styled text with message entities</a></li></ul></div>
<h1id="dev_page_title">Styled text with message entities</h1>
<divid="dev_page_content"><p>Telegram supports styled text using <ahref="/type/MessageEntity">message entities</a>.</p>
<p>A client that wants to send styled messages would simply have to integrate a <ahref="https://en.wikipedia.org/wiki/Markdown">Markdown</a>/<ahref="https://en.wikipedia.org/wiki/HTML">HTML</a> parser, and generate an array of message entities by iterating through the parsed tags.</p>
<p>Special care must be taken to consider the UTF-8 length of strings when generating message entities, see example implementations: <ahref="https://github.com/tdlib/td/tree/master/td/telegram/MessageEntity.cpp">tdlib</a>, <ahref="https://github.com/danog/MadelineProto/blob/master/src/danog/MadelineProto/TL/Conversion/BotAPI.php">MadelineProto</a>.</p>
<p>Nested entities are supported.<br>
For example the following HTML/Markdown aliases for message entities can be used:</p>
<p>The following entities can also be used to <ahref="/api/mentions">mention</a> users:</p>
<ul>
<li><ahref="/constructor/inputMessageEntityMentionName">inputMessageEntityMentionName</a> =><ahref="https://t.me/botfather">Mention a user</a></li>
<li><ahref="/constructor/inputMessageEntityMentionName">messageEntityMention</a> =><ahref="https://t.me/botfather">@botfather</a> (this mention is generated automatically server-side for @usernames in messages)</li>
</ul></div>
</div>
</div>
</div>
<divclass="footer_wrap">
<divclass="footer_columns_wrap footer_desktop">
<divclass="footer_column footer_column_telegram">
<h5>Telegram</h5>
<divclass="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.