<metaproperty="description"content="The Saved Messages chat allows users to bookmark messages and media: it's a personal cloud storage for any messages or media you may want to send or forward there.">
<metaproperty="og:title"content="Saved messages">
<metaproperty="og:image"content="">
<metaproperty="og:description"content="The Saved Messages chat allows users to bookmark messages and media: it's a personal cloud storage for any messages or media you may want to send or forward there.">
<p>The Saved Messages chat allows users to bookmark messages and media: it's a personal cloud storage for any messages or media you may want to send or forward there. </p>
<p>Internally, the Saved Messages chat is simply the private chat with ourselves (i.e. the chat with <ahref="/constructor/inputPeerSelf">inputPeerSelf</a>): the only difference between the Saved Messages chat and a chat with any other user, is that additional features are available to better organize messages and media sent to it. </p>
<p>Messages sent and forwarded from various users (including ourselves) to Saved Messages are automatically categorized by their original dialog into a saved dialog list, quite similar to the normal dialog list used to normally interact with chats. </p>
<p>To add new dialogs to the normal dialog list a user has to write to them (or join a channel/chat, etc.).<br>
To add new dialogs to the saved dialog list, simply forward messages from any normal dialog to <ahref="/constructor/inputPeerSelf">inputPeerSelf</a> (the current user): the forwarded messages (including outgoing ones) will be added to a saved dialog with the same ID of the original dialog.</p>
<p>This includes outgoing messages, for example assume the following:</p>
<ul>
<li>Our user <code>id</code> is equal to <code>11111111</code></li>
<li>We send a message A with ID <code>10</code> to a <ahref="/api/channel">supergroup</a> with <code>id=-100122222222</code> (bot API format, equivalent to a <ahref="/constructor/peerChannel">peerChannel</a> with ID <code>122222222</code>) </li>
<li>Another user with <code>id=133333333</code> replies <code>B</code> to our previous message, message ID <code>11</code></li>
<li>We forward both messages <code>A</code> and <code>B</code> with IDs <code>10</code> and <code>11</code> to <ahref="/constructor/inputPeerSelf">inputPeerSelf</a>, which will:<ul>
<li>Create a new <ahref="/constructor/savedDialog">savedDialog</a> with <code>peer=-100122222222</code> (if it doesn't exist already because we already forwarded messages from that supergroup)</li>
<li>Generate two messages:<ul>
<li>Message <code>A</code>:<ul>
<li><code>id</code>: an unrelated message ID, the next one in the common ID sequence, for example <code>1234</code></li>
<p>Saving messages from private chats with users with forward privacy enabled will add them to a saved dialog entry of a special anonymous user with <code>id=2666000</code>. </p>
<p>Clients may use the following pseudocode to manually populate the <code>saved_peer_id</code> of old <code>layer < 170</code><ahref="/constructor/message">message</a>s stored in the <strong>local</strong> database. </p>
<pre><code>// user_id is the ID of the current user.
<p>Sending (not forwarding from another dialog) new messages directly to ourselves will add them to a saved dialog entry with ourselves. </p>
<p>A set of methods can then be used to obtain this dialog list, pin/unpin dialogs inside of it, view and remove messages from saved dialogs: <ahref="/method/messages.getSavedDialogs">messages.getSavedDialogs</a>, <ahref="/method/messages.getSavedHistory">messages.getSavedHistory</a>, <ahref="/method/messages.deleteSavedHistory">messages.deleteSavedHistory</a>, <ahref="/method/messages.getPinnedSavedDialogs">messages.getPinnedSavedDialogs</a>, <ahref="/method/messages.toggleSavedDialogPin">messages.toggleSavedDialogPin</a>, <ahref="/method/messages.reorderPinnedSavedDialogs">messages.reorderPinnedSavedDialogs</a> work just like their counterparts <ahref="/method/messages.getDialogs">messages.getDialogs</a>, <ahref="/method/messages.getHistory">messages.getHistory</a>, <ahref="/method/messages.deleteHistory">messages.deleteHistory</a>, <ahref="/method/messages.getPinnedDialogs">messages.getPinnedDialogs</a>, <ahref="/method/messages.toggleDialogPin">messages.toggleDialogPin</a>, <ahref="/method/messages.reorderPinnedDialogs">messages.reorderPinnedDialogs</a>, with the sole difference that they affect the saved dialog list, instead of the main dialog list. </p>
<p>To search for messages within a saved dialog, use the usual <ahref="/method/messages.search">messages.search</a>, <ahref="/method/messages.getSearchCounters">messages.getSearchCounters</a>, <ahref="/method/messages.getSearchResultsCalendar">messages.getSearchResultsCalendar</a>, <ahref="/method/messages.getSearchResultsPositions">messages.getSearchResultsPositions</a> methods with <code>peer</code>=<ahref="/constructor/inputPeerSelf">inputPeerSelf</a> and <code>saved_peer_id</code>=id of the saved dialog. </p>
<p>For even more organization, <ahref="/api/premium">Premium users</a> can add <strong>multiple tags</strong> to your Saved Messages that let you quickly <strong>filter</strong> them in Search.</p>
<p>Tags are based on <ahref="/api/reactions">reactions»</a>: adding a tag to a saved message is as easy as <ahref="/api/reactions">reacting to it»</a> using <ahref="/method/messages.sendReaction">messages.sendReaction</a>. </p>
<p>Reactions are considered as tags only for saved messages, if the following conditions are met:</p>
<ul>
<li>The saved message did not previously have any reaction,</li>
<li>OR if the saved message already has some reactions <em>and</em> the <ahref="/constructor/messageReactions">messageReactions</a>.<code>reactions_as_tags</code> flag is set.<br>
If the <code>reactions_as_tags</code> flag is not set on a saved message with at least one reaction, the reaction was added before tags were introduced (before layer 171). In this case, to enable adding reaction tags, the user must first remove all existing reactions on the message, and then re-add the appropriate reaction tags. </li>
</ul>
<p>You may search for saved messages tagged with one or more reactions using the <code>saved_reaction</code> parameter of <ahref="/method/messages.search">messages.search</a>. </p>
<p><ahref="/method/messages.getDefaultTagReactions">messages.getDefaultTagReactions</a> can be used to fetch a default recommended list of tag reactions. </p>
<p>The user may also assign a name (max 12 UTF-8 chars) to a tag reaction using <ahref="/method/messages.updateSavedReactionTag">messages.updateSavedReactionTag</a>; to remove the name, call the same method without setting the <code>title</code> flag. </p>
<p><ahref="/method/messages.getSavedReactionTags">messages.getSavedReactionTags</a> can be used to fetch and locally cache the full list of reaction tag names assigned by the user; a <code>peer</code> may be optionally specified, to fetch only reaction tags used on messages of a specific <ahref="#saved-message-dialogs">saved message dialog</a>.<br>
Updating the name of a reaction tag will emit an <ahref="/constructor/updateSavedReactionTags">updateSavedReactionTags</a> update to all logged-in sessions except for the current one; this update should trigger a call to <ahref="/method/messages.getSavedReactionTags">messages.getSavedReactionTags</a><em>without</em> setting the <code>peer</code> flag to refresh the locally cached list. </p>
<p>If non-empty, the list of saved reaction tags returned by <ahref="/method/messages.getSavedReactionTags">messages.getSavedReactionTags</a> should be shown in the UI just below the search input bar, in descending order by <code>count</code>; if searching within a specific <ahref="#saved-message-dialogs">saved message dialog</a>, use <code>peer</code> to only return tags used in a specific saved message dialog. </p>
<p>The tag reaction selection UI, on the other hand, should first display the reactions returned by <ahref="/method/messages.getSavedReactionTags">messages.getSavedReactionTags</a> (global tag list, i.e. without <code>peer</code> regardless of the current saved message dialog) in descending order by <code>count</code>, then the reactions returned by <ahref="/method/messages.getDefaultTagReactions">messages.getDefaultTagReactions</a> that weren't already returned by <ahref="/method/messages.getSavedReactionTags">messages.getSavedReactionTags</a>, then any installed <ahref="/api/custom-emoji">custom emoji packs</a>.</p></div>