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.9
Last Updated: 2004-10-28
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 - 2004 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.php>. 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 and XMPP IM 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 protocols defined in this JEP have been developed outside the Internet Standards Process and are to be understood as extensions 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. Context of Usage
4.4. Use in Groupchat
4.5. Syntax of Notifications
4.6. Threads
4.7. Server Handling of Notifications
5. A Simple Example
6. A Detailed Conversation
7. Security Considerations
8. IANA Considerations
9. Jabber Registrar Considerations
9.1. Protocol Namespaces
10. XML Schema
Notes
Revision History


1. Introduction

The Message Events [1] protocol was an early attempt to define notifications related to message processing and composing events. However, it is informational only and 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 storage, delivery, and display events); this is confusing, especially since message delivery states are now more fully defined by Advanced Message Processing [2], which in part supersedes JEP-0022.
  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 certain events; this introduces an unnecessary dependency.
  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 'id' attribute and the <id/> element has traditionally been difficult for developers to understand; this has led to a large number of non-compliant implementations.
  5. The necessity for cancelling previously-generated composing events is introduced because the protocol does not define a complete state chart for chat conversations; this is not only incomplete but confusing.
  6. There is no message event indicating that the chat session should be considered inactive or finished.

This proposal attempts to address those issues and to provide a protocol that can be accepted as a standard by the Jabber Software Foundation.

2. Definitions

This proposal supplements the traditional "is-composing" state by defining four additional chat states, for a total of five states that together fully describe the possible states for a chat conversation. These states refer to a user's participation in the chat session, not necessarily 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.

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

  1. A User MUST NOT notify a Contact of any chat state other than <active/> until the User has discovered that the Contact supports this protocol (the same is true of the Contact).
  2. If the User desires chat state notifications, the initial message MUST contain an <active/> notification.
  3. The Contact MUST NOT send any chat state notifications to the User (e.g., a composing event) before sending a reply to the User's initial message in the conversation; the only allowable chat state notification in the initial reply is the <active/> notification.
  4. If the Contact replies to the initial message but does not include an <active/> notification, the User MUST NOT send subsequent chat state notifications to the Contact.
  5. If the Contact replies to the initial message and includes an <active/> notification, the 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 JEP-0022.)

4.3 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.4 Use in Groupchat

  1. In the context of groupchat (e.g., as defined in Multi-User Chat [3]), 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.5 Syntax of Notifications

  1. Chat state notification messages MUST contain one and only one child element qualified by the 'http://jabber.org/protocol/chatstates' namespace.
  2. A <composing/> notification message MUST NOT contain a <subject/> element or a <body/> element.

4.6 Threads

While chat state notifications provide a mechanism for managing chat threads (i.e., the <thread/> element), support for threads is OPTIONAL. However, if threads are used, 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.7 Server Handling of Notifications

Servers in constrained network environments (e.g., serving small-footprint clients via Jabber HTTP Polling [4] or HTTP Binding [5]) and services that rebroadcast message stanzas (e.g., Multi-User Chat services) MAY process 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 the Message Events protocol, 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. 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.

8. IANA Considerations

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

9. Jabber Registrar Considerations

9.1 Protocol Namespaces

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

10. 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. JEP-0079: Advanced Message Processing <http://www.jabber.org/jeps/jep-0079.html>.

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

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

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

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

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


Revision History

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