<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
  <header>
    <title>Message Replies</title>
    <abstract>
      This document defines a way to indicate that a message is a reply to a previous message.
    </abstract>
    
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
    <number>0461</number>
    <status>Experimental</status>
    <type>Standards Track</type>
    <sig>Standards</sig>
    <approver>Council</approver>
    <dependencies/>
    <supersedes/>
    <supersededby/>
    <shortname>reply</shortname>
    
  <author>
    <firstname>Natalie</firstname>
    <surname>Wirth</surname>
    <email>nataliew@laposte.net</email>
  </author>

    
  <author>
    <firstname>Marvin</firstname>
    <surname>Wißfeld</surname>
    <email>xmpp@larma.de</email>
    <jid>jabber@larma.de</jid>
  </author>

    <revision>
      <version>0.2.1</version>
      <date>2026-02-25</date>
      <initials>mye</initials>
      <remark>Update the example to use the correct fallback namespace.</remark>
    </revision>
    <revision>
      <version>0.2.0</version>
      <date>2022-12-09</date>
      <initials>nc</initials>
      <remark>Fix example character counting. Add disco feature. Relax the 'to' attribute constraints.</remark>
    </revision>
  <revision>
    <version>0.1.0</version>
    <date>2022-01-25</date>
    <initials>XEP Editor (jsc)</initials>
    <remark>Accepted by vote of Council on 2022-01-05.</remark>
  </revision>
    <revision>
      <version>0.0.1</version>
      <date>2022-01-01</date>
      <initials>nw/mw</initials>
      <remark>
        <p>First draft.</p>
      </remark>
    </revision>
  </header>

  <section1 topic="Introduction" anchor="intro">
    <p>
      When commenting on a previous message, it is sometimes desired to clarify which message the comment refers to.
      Currently, <span class="ref"><link url="https://xmpp.org/extensions/xep-0393.html">Message Styling (XEP-0393)</link></span> <note>XEP-0393: Message Styling &lt;<link url="https://xmpp.org/extensions/xep-0393.html">https://xmpp.org/extensions/xep-0393.html</link>&gt;.</note> quotes are commonly used for that purpose. However, this format does not allow receiving
      clients to properly identify the referenced message or to adjust the user interface accordingly.
    </p>
    <p>
      This specification defines a way to indicate that a message is a reply to a previous message. It does not intend
      to provide means to create sub-threads for a message.
    </p>
  </section1>

  <section1 topic="Discovering support" anchor="disco">
    <p>
      If a client implements message replies, it MUST specify the 
      'urn:xmpp:reply:0' feature in its service discovery information features
      as specified in <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note> and the Entity Capabilities profile specified in <span class="ref"><link url="https://xmpp.org/extensions/xep-0115.html">Entity Capabilities (XEP-0115)</link></span> <note>XEP-0115: Entity Capabilities &lt;<link url="https://xmpp.org/extensions/xep-0115.html">https://xmpp.org/extensions/xep-0115.html</link>&gt;.</note>.
    </p>
    <example caption="Client requests information about a chat partner's client"><![CDATA[
  <iq type='get'
      to='romeo@montague.lit/orchard'
      from='juliet@capulet.lit/balcony'
      id='info1'>
    <query xmlns='http://jabber.org/protocol/disco#info'/>
  </iq>]]></example>
    <example caption="Partner's client advertises support for replies"><![CDATA[
  <iq type='result'
      to='juliet@capulet.lit/balcony'
      from='romeo@montague.lit/orchard'
      id='info1'>
    <query xmlns='http://jabber.org/protocol/disco#info'>
  ...
      <feature var='urn:xmpp:reply:0'/>
  ...
    </query>
  </iq>]]></example>
  </section1>

  <section1 topic="Use Cases" anchor="usecases">
    <p>
      To indicate that a message is a reply, a &lt;reply&gt; element in the urn:xmpp:reply:0 namespace is placed in the
      message stanza. The &lt;reply&gt; element SHOULD have a 'to' attribute containing the full jid of the author of the
      referenced message and MUST have an 'id' attribute containing the id of the referenced message.
      In a 1:1 chat context, a bare jid MAY be used instead of a full jid.
    </p>
    <example caption="Max replies to Anna's message"><![CDATA[
<message to='max@example.com' from='anna@example.com/tablet' id='message-id1' type='chat'>
  <body>We should bake a cake</body>
</message>

<message to='anna@example.com' id='message-id2' type='chat'>
  <body>Great idea!</body>
  <reply to='anna@example.com/tablet' id='message-id1' xmlns='urn:xmpp:reply:0' />
</message>]]></example>

    <section2 topic="Compatibility Fallback" anchor="compat">
      <p>
        To provide a fallback for non-supporting clients, the sending client MAY include fallback text in the body and
        indicate it via Compatibility Fallback.
        Note that the following example is formatted for readability and that the indentation, leading and trailing new lines
        of the example body element should not be taken into account.
      </p>
      <example caption="Anna replies to a message and includes a fallback"><![CDATA[
<message to='anna@example.com' id='message-id3' type='chat'>
  <body>
    > Anna wrote:
    > We should bake a cake
    Great idea!
  </body>
  <reply to='anna@example.com/laptop' id='message-id1' xmlns='urn:xmpp:reply:0' />
  <fallback xmlns='urn:xmpp:fallback:0' for='urn:xmpp:reply:0'>
    <body start="0" end="38" />
  </fallback>
</message>]]></example>

      <p>
        The receiving client SHOULD NOT display the compatibility fallback if it renders the referenced message
        alongside the reply in some way. However, if the receiving client does not display the referenced message, for
        example because it doesn't know the referenced id, it MAY display the compatibility fallback instead.
      </p>
    </section2>
  </section1>

  <section1 topic="Business Rules" anchor="rules">
    <p>Answers MUST NOT be be assumed to relate to any other messages than the referenced one.</p>
    <section2 topic="Using the correct ID" anchor="business-id">
      <p>
        For messages of type 'groupchat', the stanza's 'id' attribute MUST NOT be used for replies. Instead, in group
        chat situations, the ID assigned to the stanza by the group chat itself must be used. This is discovered in a
        &lt;stanza-id&gt; element with a 'by' attribute that matches the bare JID of the group chat, as defined
        in <span class="ref"><link url="https://xmpp.org/extensions/xep-0359.html">Unique and Stable Stanza IDs (XEP-0359)</link></span> <note>XEP-0359: Unique and Stable Stanza IDs &lt;<link url="https://xmpp.org/extensions/xep-0359.html">https://xmpp.org/extensions/xep-0359.html</link>&gt;.</note>.
      </p>
      <p>
        This implies that group chat messages without a <span class="ref"><link url="https://xmpp.org/extensions/xep-0359.html">Unique and Stable Stanza IDs (XEP-0359)</link></span> <note>XEP-0359: Unique and Stable Stanza IDs &lt;<link url="https://xmpp.org/extensions/xep-0359.html">https://xmpp.org/extensions/xep-0359.html</link>&gt;.</note> stanza-id cannot be replied to.
      </p>
      <p>
        For other message types the sender should use the 'id' from a <span class="ref"><link url="https://xmpp.org/extensions/xep-0359.html">Unique and Stable Stanza IDs (XEP-0359)</link></span> <note>XEP-0359: Unique and Stable Stanza IDs &lt;<link url="https://xmpp.org/extensions/xep-0359.html">https://xmpp.org/extensions/xep-0359.html</link>&gt;.</note>
        &lt;origin-id&gt; if present, or the value of the 'id' attribute on the
        &lt;message&gt; otherwise.
      </p>
    </section2>
  </section1>

  <section1 topic="IANA Considerations" anchor="iana">
    <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
  </section1>

  <section1 topic="XMPP Registrar Considerations" anchor="registrar">
    <p>This document requires no interaction with <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note>.</p>
  </section1>

</xep>
