XEP-0201: Best Practices for Message Threads

This specification defines recommended handling of XMPP message threads.


WARNING: This Informational document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the best practice or protocol profile described herein is encouraged in exploratory implementations, although production systems should not deploy implementations of this protocol until it advances to a status of Draft.


Document Information

Series: XEP
Number: 0201
Publisher: XMPP Standards Foundation
Status: Experimental
Type: Informational
Version: 0.4
Last Updated: 2007-08-30
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: None
Short Name: N/A
Wiki Page: <http://wiki.jabber.org/index.php/Best Practices for Message Threads (XEP-0201)>


Author Information

Peter Saint-Andre

JabberID: stpeter@jabber.org
URI: https://stpeter.im/

Ian Paterson

Email: ian.paterson@clientside.co.uk
JabberID: ian@zoofy.com

Kevin Smith

Email: kevin@kismith.co.uk
JabberID: kevdadrum@jabber.ex.ac.uk


Legal Notices

Copyright

This XMPP Extension Protocol is copyright (c) 1999 - 2008 by the XMPP Standards Foundation (XSF).

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.

Disclaimer of 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. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##

Limitation of 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 out of the use or inability to use 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.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://www.xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Discussion Venue

The preferred venue for discussion of this document is the Standards discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.

Errata may be sent to <editor@xmpp.org>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Conformance Terms

The following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Table of Contents


1. Introduction
2. Motivation
3. Semantics
4. Uniqueness
5. Handling
    5.1. Chat Messages
    5.2. Groupchat Messages
    5.3. Headline Messages
    5.4. Normal Messages
    5.5. Messages That Have Been Archived
6. Inclusion
7. SHIM Header
8. Implementation Notes
9. Security Considerations
10. IANA Considerations
11. XMPP Registrar Considerations
    11.1. SHIM Headers Registry
Notes
Revision History


1. Introduction

Although message threads are re-used in XMPP extension protocols such as Chat State Notifications [1] and Stanza Session Negotiation [2], the semantics of message threads have never been well specified (e.g., in RFC 3921 [3]). This document attempts to clearly specify the meaning and handling of message threads for implementation by XMPP clients and for potential inclusion in rfc3921bis [4].

2. Motivation

Threads matter because they enable XMPP clients to:

3. Semantics

Section 2.1.2.3 of RFC 3921 currently states the following regarding the semantics of the ThreadID:

The <thread/> element contains non-human-readable XML character data specifying an identifier that is used for tracking a conversation thread (sometimes referred to as an "instant messaging session") between two entities.

The description in RFC 3921 is deemed to be too limiting, since it ignores the potential use of the ThreadID when exchanging message stanzas of types other than "chat". Therefore we propose the following description:

The primary use of the XMPP <thread/> element is to uniquely identify a conversation thread or "chat session" between two entities instantiated by <message/> stanzas of type "chat". However, the XMPP <thread/> element may also be used to uniquely identify an analogous thread between two entities instantiated by <message/> stanzas of type "headline" or "normal", or among multiple entities in the context of a multi-user chat room instantiated by <message/> stanzas of type "groupchat". It may also be used for <message/> stanzas not related to a conversation, such as a game session or between plugins.

4. Uniqueness

Section 2.1.2.3 of RFC 3921 currently states the following uniqueness requirement:

The value of the <thread/> element ... MUST be unique to that conversation thread within the stream and MUST be consistent throughout that conversation (a client that receives a message from the same full JID but with a different thread ID MUST assume that the message in question exists outside the context of the existing conversation thread).

The uniqueness requirement in RFC 3921 is not deemed strong enough since it is desirable that a ThreadID could be used to (for instance) restart a conversation at a later date. Therefore we propose the following uniqueness requirement:

The value of the <thread/> element MUST be a universally unique identifier (UUID). The format described in RFC 4122 [6] is RECOMMENDED.

5. Handling

5.1 Chat Messages

In the context of <message/> stanzas of type "chat" exchanged between two entities, the value of the <thread/> element shall be considered equivalent to a unique identifier for the chat session or conversation thread. If an entity receives such a message with a new or unknown ThreadID, it SHOULD treat the message as part of a session with unnegotiated parameters (i.e., as equivalent to the first message in a chat session that has been negotiated via XEP-0155 with no parameters specified). An entity SHOULD destroy the thread when it sends or receives a XEP-0155 "terminate" stanza (such a stanza SHOULD be sent even for sessions that were not negotitated with XEP-0155) and MAY destroy the thread when it goes offline, but SHOULD NOT destroy the thread if a human user merely disengages from the chat session (e.g., by closing a window in a client interface).

If an entity receives an XMPP presence stanza of type "unavailable" from the other entity during a chat session, it SHOULD NOT destroy the thread; instead, it SHOULD assume that the other entity will still be able to continue the session (perhaps the other entity simply became "invisible", was temporarily disconnected by a network error, or is persisting the state of the session until it reconnects and receives "offline" messages).

If an entity receives a message of type "chat" without a thread ID then:

5.2 Groupchat Messages

In the context of <message/> stanzas of type "groupchat" exchanged between multiple entities in a Multi-User Chat [7] room or similar environment, the value of the <thread/> element shall be considered equivalent to a unique identifier for a conversation thread in the multi-user environment.

When displaying threaded groupchat conversation within a user interface, a client SHOULD provide a visual indication of the thread to which a message belongs. Methods for such indications include (non-exhaustively) the grouping together of all messages from the same thread, providing an index of threads, or formatting all messages within a thread in a cohesive manner, e.g. with uniform coloring.

5.3 Headline Messages

There are no special handling requirements related to threads in the context of <message/> stanzas of type "headline".

5.4 Normal Messages

When sending a <message/> stanza of type "normal", the value of the <thread/> element is used to uniquely identify a conversation thread that may not be progressing in real-time. A <message/> stanza of type "normal" SHOULD always use a new <thread/> element identifier unless it is written in direct reply to another <message/> stanza, in which case the <thread/> element of the original <message/> should be used. Determining what constitutes a <message/> stanza written in reply to another is a matter left to individual implementation, but it is envisaged that in most cases it would be the result of, e.g., the user clicking a 'reply' button when reading the contents of the previous stanza; alternatively, the entity that replies can include an "In-Reply-To" header as described in the Implementation Notes section of this document.

5.5 Messages That Have Been Archived

When displaying historical conversations within a user interface, a client SHOULD provide a visual indication of the thread to which a message belongs. Methods for such indications include (non-exhaustively) the grouping together of all messages from the same thread, providing an index of threads, or formatting all messages within a thread in a cohesive manner, e.g. with uniform coloring.

6. Inclusion

Depending on the type of the message (i.e., the value of the 'type' attribute), the <thread/> should be included as follows:

Table 1: When to Include Threads

Message Type Inclusion
chat RECOMMENDED
groupchat RECOMMENDED
headline OPTIONAL
normal OPTIONAL

7. SHIM Header

In some contexts it may be desirable to enforce thread-like semantics when exchanging XMPP <iq/> stanzas. Because RFC 3920 disallows more than one direct child element of the <iq/> stanza, it is not possible to include the <thread/> element for tracking purposes. Therefore we define a "ThreadID" Stanza Headers and Internet Metadata [8] header with the same semantics as the <thread/> element, but with the syntax of a SHIM header:

Example 1. ThreadID header

<iq from='romeo@montague.net/home'
    to='joogle@botster.shakespeare.lit'
    type='get'
    id='create1'>
  <command xmlns='http://jabber.org/protocol/commands'
           node='create'
           action='execute'>
    <headers xmlns='http://jabber.org/protocol/shim'>
      <header name='ThreadID'>e0ffe42b28561960c6b12b944a092794b9683a38</header>
    </headers>
  </command>
</iq>
  

8. Implementation Notes

An entity that needs to track replies to particular messages may do so by including an 'id' attribute with the <message/> stanza.

Example 2. Message with ID

<message
    to='romeo@example.net/orchard'
    from='juliet@example.com/balcony'
    id='asiwe8289ljfdalk'
    type='chat'
    xml:lang='en'>
  <body>Art thou not Romeo, and a Montague?</body>
  <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
</message>
  

The entity that replies then MAY include an "In-Reply-To" SHIM header:

Example 3. Reply

<message
    to='juliet@example.com/balcony'
    from='romeo@example.net/orchard'
    type='chat'
    id='pertio4387435ilq'
    xml:lang='en'>
  <body>Neither, fair saint, if either thee dislike.</body>
  <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
  <headers xmlns='http://jabber.org/protocol/shim'>
    <header name='In-Reply-To'>asiwe8289ljfdalk</header>
  </headers>
</message>
  

9. Security Considerations

An entity that generates the UUID used as the ThreadID MUST ensure that the UUID does not reveal identifying information about the entity.

10. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [9].

11. XMPP Registrar Considerations

11.1 SHIM Headers Registry

The XMPP Registrar shall add "ThreadID" to its registry of SHIM headers (see <http://www.xmpp.org/registrar/shim.html>). The submission is as follows:

<header>
  <name>ThreadID</name>
  <desc>
    This header has the same semantics as the thread child element
    of the XMPP message stanza but is for use in IQ stanzas.
  </desc>
  <doc>XEP-0201</doc>
</header>
    

Notes

1. XEP-0085: Chat State Notifications <http://www.xmpp.org/extensions/xep-0085.html>.

2. XEP-0155: Stanza Session Negotiation <http://www.xmpp.org/extensions/xep-0155.html>.

3. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc3921>.

4. rfc3921bis: proposed revisions to Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/draft-saintandre-rfc3921bis>. (work in progress)

5. XEP-0045: Multi-User Chat <http://www.xmpp.org/extensions/xep-0045.html>.

6. RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace <http://tools.ietf.org/html/rfc4122>.

7. XEP-0045: Multi-User Chat <http://www.xmpp.org/extensions/xep-0045.html>.

8. XEP-0131: Stanza Headers and Internet Metadata <http://www.xmpp.org/extensions/xep-0131.html>.

9. 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 <http://www.iana.org/>.


Revision History

Version 0.4 (2007-08-30)

Specified handling of thread IDs on groupchat messages.

(psa)

Version 0.3 (2007-01-29)

Described handling of unavailable presence and chat messages without thread IDs; minor changes.

(ip)

Version 0.2 (2007-01-23)

Equalized treatment of different message types (chat and groupchat not preferred over normal); required the use of UUIDs; specified use of In-Reply-To header; added Kevin Smith as co-author.

(psa/ks)

Version 0.1 (2006-12-20)

Initial version.

(psa)

Version 0.0.2 (2006-12-14)

Corrected SHIM example; added XMPP Registrar considerations. (psa)

Version 0.0.1 (2006-12-13)

First draft. (psa/ip)

END