<metaproperty="description"content="Telegram allows commenting on a [channel post](/api/channel) or on a generic [supergroup message](/api/channel), thanks to message threads.">
<metaproperty="og:title"content="Threads">
<metaproperty="og:image"content="">
<metaproperty="og:description"content="Telegram allows commenting on a [channel post](/api/channel) or on a generic [supergroup message](/api/channel), thanks to message threads.">
<p>Telegram allows commenting on a <ahref="/api/channel">channel post</a> or on a generic <ahref="/api/channel">supergroup message</a>, thanks to message threads.</p>
<p>Threads are usually automatically created when replying to any message in a group.<br>
For example, all replies to a message with ID <code>420</code> are associated to thread with ID <code>420</code>, unique to this group; this thread ID is contained in the <code>reply_to_top_id</code> field of <code>reply_to</code><ahref="/constructor/messageReplyHeader">messageReplyHeader</a>, along with an eventual <code>reply_to_msg_id</code>, for replies to messages within a thread.<br>
Replies to messages in a thread are part of the same thread, and do not spawn new threads. </p>
<p>When receiving a <ahref="/constructor/message">message</a> from a group that is also the top of a thread (the message with ID <code>420</code>), the <code>replies</code> optional field will contain a <ahref="/constructor/messageReplies">messageReplies</a> constructor, containing the message ID and <ahref="/api/updates">PTS</a> of the latest reply in the thread, and the message ID of the latest read thread reply, along with the total number of replies in the thread. </p>
<p>Replies to a thread can also be manually fetched using <ahref="/method/messages.search">messages.search</a>, providing to <code>top_msg_id</code> the thread ID. </p>
<p>The same <ahref="/constructor/messageReplies">messageReplies</a> constructor seen above will also be contained in channel posts, this time containing information about the comment section of a specific channel post.<br>
The comment section of a channel post is simply the <ahref="#message-thread">message thread</a> of the automatically forwarded channel message in the <ahref="/api/discussion">linked discussion supergroup</a>; the ID of the linked discussion supergroup will be contained in the <code>messageReplies.channel_id</code> field. </p>
<p>For channel posts, the <code>recent_repliers</code> field will also contain information about the last few comment posters for a specific thread, to show a small list of commenter profile pictures in client previews.</p>
<p>Since a user can comment in channel posts without joining the actual <ahref="/api/discussion">discussion supergroup</a>, there must be a way for them to receive notifications about replies in comment sections.<br>
For this reason, a special <code>@replies</code> username is provided.
Its ID for main and testing endpoints can be seen in the <ahref="https://github.com/tdlib/td/blob/34cf869c02583c23b023f725dca30cd18efc82a3/td/telegram/ContactsManager.cpp#L4418">tdlib sources</a>. </p>
<p>When someone replies to one of our messages in the comment section of a channel post, and the user is not subscribed to the discussion group, the client will receive two updates:</p>
<ul>
<li>An <ahref="/constructor/updateNewChannelMessage">updateNewChannelMessage</a> from the discussion group itself, structured just like any other update coming from a subscribed group, with:<ul>
<li><code>id</code> set to the ID of the reply</li>
<li><code>from_id</code> set to the peer that replied to us</li>
<li><code>peer_id</code> set to the peer of the <ahref="/api/discussion">discussion group</a></li>
<li><code>reply_to.reply_to_msg_id</code> set to the ID of our message</li>
<li><code>reply_to.reply_to_top_id</code> set to the <ahref="/api/threads">thread ID</a>. </li>
<li><code>id</code> set to the common ID sequence for users</li>
<li><code>from_id</code> set to the peer of <code>@replies</code></li>
<li><code>peer_id</code> set to our own peer</li>
<li><code>fwd_from.saved_from_msg_id</code> set to the ID of the reply</li>
<li><code>fwd_from.from_id</code> set to the the peer that replied to us</li>
<li><code>reply_to.reply_to_peer_id</code> set to the peer of the <ahref="/api/discussion">discussion group</a></li>
<li><code>reply_to.reply_to_msg_id</code> set to the ID of our message</li>
<li><code>reply_to.reply_to_top_id</code> set to the <ahref="/api/threads">thread ID</a></li>
</ul>
</li>
</ul>
<p>Clients should display messages coming from <code>@replies</code> as a read-only supergroup, with each reply displayed as a separate message from the author of the reply, with a "View in chat" button like for channel comments. </p></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.