JEP-0085: Chat State Notifications

This JEP defines a standards-track protocol for communicating notifications related to chat states, including message composing events.


WARNING: This Standards-Track JEP is Experimental. Publication as a Jabber Enhancement Proposal does not imply approval of this proposal by the Jabber Software Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems should not deploy implementations of this protocol until it advances to a status of Draft.


JEP Information

Status: Experimental
Type: Standards Track
Number: 0085
Version: 0.13
Last Updated: 2005-07-19
JIG: Standards JIG
Approving Body: Jabber Council
Dependencies: XMPP Core, XMPP IM
Supersedes: JEP-0022
Superseded By: None
Short Name: chatstates

Author Information

Peter Saint-Andre

Email: stpeter@jabber.org
JID: stpeter@jabber.org

Dave Smith

Email: dizzyd@jabber.org
JID: dizzyd@jabber.org

Legal Notice

This Jabber Enhancement Proposal is copyright 1999 - 2005 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.jabber.org/jsf/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at <http://www.opencontent.org/openpub/>).

Discussion Venue

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

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 Jabber Software 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 JEP 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 keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.


Table of Contents

1. Introduction
2. Definitions
3. State Chart
4. Business Rules
4.1. Discovery of Support and Generation of Notifications
4.2. Support Requirements
4.3. Repetition
4.4. Context of Usage
4.5. Use in Groupchat
4.6. Syntax of Notifications
4.7. Threads
4.8. Server Handling of Notifications
5. A Simple Example
6. A Detailed Conversation
7. Implementation Notes
8. Security Considerations
9. IANA Considerations
10. Jabber Registrar Considerations
10.1. Protocol Namespaces
11. Superseding JEP-0022
12. XML Schema
Notes
Revision History


1. Introduction

Many instant messaging systems include notifications about the state of one's conversation partner in a one-to-one chat (or, sometimes, in a many-to-many chat). Usually these are limited to notification that one's partner is currently typing -- e.g., the Composing event in JEP-0022 (see Message Events [1]). However, a composing event is essentially information about a person's participation in or involvement with the chat "session" and therefore is really a session-level state rather than a per-message event -- e.g., the Delivered and Displayed events in JEP-0022. While the composing event is interesting, the concept of a session-level state can be extended to answer a variety of questions about the participation of a person in a real-time chat conversation, such as:

To answer such questions, this JEP supplements the traditional composing state by defining four additional chat states (paused, active, inactive, gone), for a total of five states that (it is hoped) together fully describe the possible states of a person's participation in or involvement with a chat conversation. [2]

Note: This JEP is intended to supersede much of the Historical message events protocol documented in JEP-0022; for details, refer to the Superseding JEP-0022 section of this JEP.

2. Definitions

In essence, chat state notifications can be thought of as a form of chat-specific presence. For example, consider what might happen if a user "loses" a chat window on his desktop; the user might still be interacting with his messaging client (thus never automatically changing his basic presence to "away"), but the user's state with regard to the chat session might change progressively from active to inactive to gone. This information would help the user's conversation partner understand why she has not received a response to her messages in the chat session.

The five chat states addressed in this document are described below. The suggested triggers are simply that: suggestions. It is up to the implementation to determine its own rules for generation of chat state notifications.

Table 1: Chat States

State Definition Suggested Triggers
<active/> User is actively participating in the chat session. User accepts initial chat message, sends a message, gives focus to the chat interface, or is otherwise paying attention to the conversation.
<composing/> User is composing a message. User interacts with an input interface specific to this chat session (e.g., types in the input area of a chat window).
<paused/> User had been composing but now has stopped. User was composing but stops interacting with the input interface for a short period of time (e.g., 5 seconds) or starts interacting with another chat interface or application.
<inactive/> User is not actively participating in the chat session. User does not interact with the chat interface for an intermediate period of time (e.g., 30 seconds), minimizes the chat interface, or starts interacting with another chat interface or application.
<gone/> User has ended their participation in the chat session. User terminates the chat interface (e.g., closes a chat window) or does not interact with the chat interface, system, or device for a long period of time (e.g., 2 minutes).

3. State Chart

The following figure attempts to capture the possible state transitions in visual form.


                o (start)
                |
                |
INACTIVE <--> ACTIVE <--> COMPOSING 
    |           ^            |
    |           |            |
    + <------ PAUSED <-----> +
  

Note: All four of the states shown may transition to the GONE state.

4. Business Rules

4.1 Discovery of Support and Generation of Notifications

In the absence of explicit negotiation of a chat session between the User and the Contact (e.g., as specified in Chat Session Negotiation [3]) or explicit discovery by the User of the Contact's capabilities (e.g., as gained through Service Discovery [4] or Entity Capabilities [5]), the following business rules apply to the use of chat state notifications in the context of one-to-one chat sessions:

  1. If the User desires chat state notifications, the initial message sent to the Contact MUST contain a chat state notification extension, which SHOULD be <active/>.
  2. Until receiving a reply to the initial message (or a standalone chat state notification message) from the Contact, the User MUST NOT send subsequent chat state notifications to the Contact.
  3. If the Contact replies to the initial message but does not include a chat state notification extension, the User MUST NOT send subsequent chat state notifications to the Contact.
  4. If the Contact replies to the initial message and includes an <active/> notification (or sends a standalone chat state notification message to the User), the User and Contact SHOULD send subsequent notifications for supported chat states as specified in the next subsection.

4.2 Support Requirements

Table 2: Requirements for Supporting Each Chat State

Chat State Requirement
<active/> MUST
<composing/> MUST
<paused/> SHOULD
<inactive/> SHOULD
<gone/> SHOULD

A client MUST allow the user to configure whether he or she wants to send chat state notifications.

Note: Support for only <active/> and <composing/> is functionally equivalent to supporting the Composing event from JEP-0022.

4.3 Repetition

Even if the user types continuously for a long time (e.g., while composing a lengthy reply), the client MUST NOT send more than one <composing/> notification in a row. More generally, a client MUST NOT send a second instance of any given chat state notification (i.e., any given notification MUST be followed by a different state, not repetition of the same state).

4.4 Context of Usage

  1. This protocol MUST NOT be used with stanzas other than <message/>.
  2. This protocol SHOULD NOT be used with message types other than "chat" or "groupchat".
  3. The 'type' attribute for chat state notification messages SHOULD be set to a value of "chat" or "groupchat" (as appropriate for the context).
  4. A chat session MAY span multiple user sessions (i.e., chat state is orthogonal to the availability and presence of one's conversation partner), although this is unlikely given the suggested timing of event triggers.

4.5 Use in Groupchat

  1. In the context of groupchat (e.g., as defined in Multi-User Chat [6]), a client SHOULD NOT generate <gone/> notifications, and SHOULD ignore <gone/> notifications received from other room occupants.

Note: Use of chat state notifications in the context of groupchat may result in multicasting of such notifications. Forewarned is forearmed.

4.6 Syntax of Notifications

  1. A message stanza MUST NOT contain more than one child element qualified by the 'http://jabber.org/protocol/chatstates' namespace.
  2. A message stanza that contains standard messaging content -- i.e., the <body/>, <subject/>, and <thread/> child elements defined in XMPP IM [7] and/or any other properly-namespaced child element(s) -- SHOULD NOT contain a chat state notification extension other than <active/>.
  3. A message stanza that does not contain standard messaging content and is intended to specify only the chat state MUST NOT contain any child elements other than the chat state notification extension, which SHOULD be a state other than <active/>; however, if threads are used (see below) then the standalone chat state notification message MUST also contain the <thread/> element.

4.7 Threads

While chat state notifications provide a mechanism for managing chat threads (i.e., the <thread/> element), support for threads is OPTIONAL. However, if all of the clients participating in a chat both support and use threads, the following additional business rules apply:

  1. Clients MUST copy back Thread IDs (i.e., the value of the <thread/> element) in any replies.
  2. When a client terminates a one-to-one chat session (e.g., when a user closes the chat session interface), it MUST generate a <gone/> event.
  3. Upon receiving a <gone/> event, a client MUST NOT re-use the same Thread ID and MUST generate a new Thread ID for any subsequent chat messages sent to the conversation partner.

4.8 Server Handling of Notifications

Servers in constrained network environments (e.g., serving small-footprint clients via Jabber HTTP Polling [8] or HTTP Binding [9]) and services that rebroadcast message stanzas (e.g., Multi-User Chat services) MAY process standalone chat state notification messages differently from other messages. In particular, a server or service MAY refuse to deliver standalone chat state notifications to its users, and SHOULD NOT store them offline. In contrast to JEP-0022, chat state notifications are completely the responsibility of the client, and MUST NOT be generated by a server or service.

5. A Simple Example

In the following conversation, both User and Contact support chat state notifications.

Example 1. User Sends Initial Message With <active/> Notification

<message 
    from='bernardo@shakespeare.lit/pda'
    to='francisco@shakespeare.lit'
    type='chat'>
  <body>Who's there?</body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Example 2. Contact's Client Sends Reply Plus <active/> Notification

<message 
    from='francisco@shakespeare.lit/elsinore'
    to='bernardo@shakespeare.lit/pda'
    type='chat'>
  <body>Nay, answer me: stand, and unfold yourself.</body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Because the User now knows that the Contact supports chat state notifications, the User can send other notification types.

Example 3. User Sends <composing/> Notification

<message 
    from='bernardo@shakespeare.lit/pda'
    to='francisco@shakespeare.lit/elsinore'
    type='chat'>
  <composing xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Example 4. User Sends a Reply With <active/> Notification

<message 
    from='bernardo@shakespeare.lit/pda'
    to='francisco@shakespeare.lit/elsinore'
    type='chat'>
  <body>Long live the king!</body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

And so forth.

6. A Detailed Conversation

The following conversation flow illustrates in more detail the workings of chat state notifications (in this case also using threads).

Example 5. User Sends Initial Message

<message 
    from='romeo@shakespeare.lit/orchard'
    to='juliet@capulet.com'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <body>
    I take thee at thy word:
    Call me but love, and I'll be new baptized;
    Henceforth I never will be Romeo.
  </body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

At this point Juliet's client knows that Romeo's client supports chat state notifications. Thus she replies to the initial message and her client includes a notification that her state is <active/>:

Example 6. Contact's Client Sends Reply Plus <active/> Notification

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <body>
    What man art thou that thus bescreen'd in night
    So stumblest on my counsel?
  </body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

And so the conversation continues. After a while, Juliet asks a question that brings Romeo up short. Romeo begins composing a reply to Juliet's heartfelt question, and his Jabber client notifies Juliet that he is composing a reply.

Example 7. User's Client Sends <composing/> Notification

<message 
    from='romeo@montague.net/orchard' 
    to='juliet@capulet.com/balcony'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <composing xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Romeo realizes his reply is too rash and pauses to choose the right words; after some (configurable) time period, his Jabber client senses the delay and sends a state of <paused/>.

Example 8. User's Client Sends <active/> Notification

<message 
    from='romeo@montague.net/orchard' 
    to='juliet@capulet.com/balcony'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <paused xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Romeo starts composing again, and his Jabber client sends a <composing/> notification to Juliet's client.

Example 9. User's Clients Sends <composing/> Notification

<message 
    from='romeo@montague.net/orchard' 
    to='juliet@capulet.com/balcony'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <composing xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Romeo finally sends his reply.

Example 10. User Replies

<message 
    from='romeo@montague.net/orchard' 
    to='juliet@capulet.com/balcony'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <body>Neither, fair saint, if either thee dislike.</body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

The conversation ebbs and flows, waxes and wanes, until Juliet is called away by her Nurse...

Example 11. Contact's Client Sends Message

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <body>
    I hear some noise within; dear love, adieu!
    Anon, good nurse! Sweet Montague, be true.
    Stay but a little, I will come again.
  </body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

We suppose that Juliet minimizes the chat window, so her client generates an <inactive/> notification:

Example 12. Contact's Client Sends <inactive/> Notification

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <inactive xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

When she returns and brings the window up again, her client generates an <active/> notification:

Example 13. Contact's Client Sends <active/> Notification

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

The conversation continues, but Juliet is called away again by that nagging Nurse:

Example 14. Contact's Client Sends Message

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <body>
    A thousand times good night!
  </body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

We suppose that Juliet closes the chat window, so her client generates a <gone/> notification:

Example 15. Contact's Client Sends <gone/> Notification

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat1</thread>
  <gone xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

Romeo's client now considers the chat thread to be over and generates a new Thread ID when he sends a new message:

Example 16. User's Client Sends Message with New Thread ID

<message 
    from='romeo@shakespeare.lit/orchard'
    to='juliet@capulet.com/balcony'
    type='chat'>
  <thread>act2scene2chat2</thread>
  <body>
    A thousand times the worse, to want thy light.
    Love goes toward love, as schoolboys from their books,
    But love from love, toward school with heavy looks.
  </body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

When Juliet returns to her computer on the balcony, she finds the new message from Romeo. When she finishes her reply, her client includes both an <active/> notification and the new Thread ID with the body of her reply:

Example 17. Contact's Client Sends Message

<message 
    from='juliet@capulet.com/balcony'
    to='romeo@shakespeare.lit/orchard'
    type='chat'>
  <thread>act2scene2chat2</thread>
  <body>
    Hist! Romeo, hist! O, for a falconer's voice,....
  </body>
  <active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
  

And so forth.

My, these star-crossed lovers do go on, don't they?

7. Implementation Notes

A client that receives a chat state notification should expect that it may never receive another message or chat state notification from the other entity (e.g., because the other entity crashes or goes offline) and should plan accordingly.

8. Security Considerations

The states of a chat thread may reveal information about a user's interaction with his or her computer, including his or her physical presence; such information SHOULD NOT be revealed to conversation partners who are not trusted to know such information. Client implementations MUST provide a mechanism that enables the user to disable chat state notifications if desired.

9. IANA Considerations

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

10. Jabber Registrar Considerations

10.1 Protocol Namespaces

The Jabber Registrar [11] shall include 'http://jabber.org/protocol/chatstates' in its registry of protocol namespaces.

11. Superseding JEP-0022

This JEP proposes to supersede (parts of) JEP-0022, an Historical JEP that documents a protocol that has been in use within the Jabber community since the year 2000. Some justification is in order.

The message events protocol was an early attempt to define notifications related to (1) processing of messages by clients (the Delivered and Displayed events) and servers (the Offline event) as well as (2) a person's involvement in the conversation (the Composing event). We argue that the message events protocol has the following drawbacks:

  1. Message events are used both to communicate the state of one's conversation partner (the Composing event) and to track message delivery states (the Offline, Delivered, and Displayed events); this is confusing, especially since the Offline and Delivered states are now more fully defined by Advanced Message Processing [12], which in part supersedes JEP-0022. [13]

  2. Message events can be generated either by a client or by a server, and the sender must depend on the recipient's server in order to receive notification of the Offline event; this introduces an unnecessary dependency (although it must be noted that no servers ever implemented the Offline event as far as we know).

  3. Message events must be requested on a per-message basis; this is not only verbose but unnecessary in the context of most chat conversations, and requires implementations to maintain a more complex state machine than is desirable.

  4. The connection between the <message/> stanza's 'id' attribute and the JEP-0022 <id/> element has traditionally been quite difficult for implementors to keep straight (especially in the context of the typical, rapid-fire IM discussion); this has led to a large number of non-compliant implementations.

  5. The protocol does not define a complete state chart for message events; among other things this introduces the necessity for cancelling previously-generated composing events, which again has confused implementors.

  6. The composing event is useful but limited; for example, there is no message event indicating that one's conversation party is no longer actively involved in the chat or is gone.

  7. Many implementors have used only the Composing event (ignoring the Delivered and Displayed events); yet the Composing event is better seen as a session-level state (as in JEP-0085) rather than a per-message event (as in JEP-0022), which led the authors of this JEP to generalize the concept of session-level states as defined herein.

In general, the message events protocol enabled the Jabber community to experiment with the concept of per-message and session-level events. The results of that experiment are two-fold:

  1. Per-message events need to be more robust than what is defined in JEP-0022 in order to meet the need for more reliable delivery of <message/> stanzas; this led directly to the development of JEP-0079.
  2. Session-level events can provide more complete and helpful information than simply the composing state; this led directly to the development of JEP-0085.

JEP-0022 is not bad or evil, but it has outlived its usefulness. We have done better for message events (JEP-0079) and it is time to do better for session events (JEP-0085).

12. XML Schema

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/chatstates'
    xmlns='http://jabber.org/protocol/chatstates'
    elementFormDefault='qualified'>

  <xs:element name='active' type='empty'/>
  <xs:element name='composing' type='empty'/>
  <xs:element name='gone' type='empty'/>
  <xs:element name='inactive' type='empty'/>
  <xs:element name='paused' type='empty'/>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
  


Notes

1. JEP-0022: Message Events <http://www.jabber.org/jeps/jep-0022.html>.

2. These states do not necessarily refer to the state of the client interface and certainly not to the disposition of a particular message. However, the user's involvement with the system, device, chat interface, or input interface can provide important clues regarding the user's involvement with the chat session, which should be used by the client in determining when to generate chat state notifications.

3. JEP-0155: Chat Session Negotiation <http://www.jabber.org/jeps/jep-0155.html>.

4. JEP-0030: Service Discovery <http://www.jabber.org/jeps/jep-0030.html>.

5. JEP-0115: Entity Capabilities <http://www.jabber.org/jeps/jep-0115.html>.

6. JEP-0045: Multi-User Chat <http://www.jabber.org/jeps/jep-0045.html>.

7. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://www.ietf.org/rfc/rfc3921.txt>.

8. JEP-0025: Jabber HTTP Polling <http://www.jabber.org/jeps/jep-0025.html>.

9. JEP-0124: HTTP Binding <http://www.jabber.org/jeps/jep-0124.html>.

10. 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/>.

11. The Jabber Registrar maintains a list of reserved Jabber protocol namespaces as well as registries of parameters used in the context of protocols approved by the Jabber Software Foundation. For further information, see <http://www.jabber.org/registrar/>.

12. JEP-0079: Advanced Message Processing <http://www.jabber.org/jeps/jep-0079.html>.

13. The JEP-0022 Delivered state was to be raised by the client rather than the server; however, it is effectively superseded by the JEP-0079 deliver condition.


Revision History

Version 0.13 (2005-07-19)

Further clarified business rules regarding generation of notifications. (psa)

Version 0.12 (2005-07-15)

Clarified business rules regarding generation of notifications; added reference to JEP-0155; rewrote introduction; moved previous introductory text to section on superseding JEP-0022. (psa)

Version 0.11 (2005-07-05)

Removed <initial/> state. (psa)

Version 0.10 (2005-06-28)

Added optional <initial/> state; added business rule on repetition of notifications; added implementation note. (psa)

Version 0.9 (2004-10-28)

Made <inactive/> state definition consistent with <paused/> per list discussion; made slight adjustments to wording throughout. (psa)

Version 0.8 (2004-10-28)

Further clarified state definitions and adjusted suggested event timing. (psa)

Version 0.7 (2004-10-27)

Clarified the meaning of the <gone/> state; adjusted suggested timing for events. (psa)

Version 0.6 (2004-02-19)

Added <paused/> state; defined the chat states; clarified the state chart; simplified the business rules. (psa)

Version 0.5 (2003-09-18)

Clarified that 'type' must be "chat" or "groupchat" for chat state notification messages. (psa)

Version 0.4 (2003-05-22)

Made Thread IDs optional; made <inactive/> and <gone/> states optional if Thread IDs are not used; removed requirement for explicit service discovery in favor of implicit discovery. (psa)

Version 0.3 (2003-05-20)

Clarified terminology; added support for groupchat; added several implementation notes. (psa)

Version 0.2 (2003-05-19)

General cleanup; added schema. (psa)

Version 0.1 (2003-05-19)

Initial version. (dss/psa)


END