JEP-0085: Chat State Notifications

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


NOTICE: This JEP is currently within Last Call or under consideration by the Jabber Council for advancement to the next stage in the JSF standards process. For further details, visit <http://www.jabber.org/council/queue.shtml>.


JEP Information

Status: Proposed
Type: Standards Track
Number: 0085
Version: 0.14
Last Updated: 2005-07-20
JIG: Standards JIG
Approving Body: Jabber Council
Dependencies: XMPP Core, XMPP IM
Supersedes: None
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. 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]

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.

Chat state notifications can appear in two kinds of <message/> stanzas:

The five chat states specified in this document are described below. The suggested triggers and state changes are simply that: suggestions. It is up to the implementation to determine when to generate chat state notifications and which notifications to generate.

Table 1: Chat States

State Definition Suggested Triggers Suggested State Changes
<active/> User is actively participating in the chat session. User accepts an initial content message, sends a content message, gives focus to the chat interface, or is otherwise paying attention to the conversation. <inactive/>, <composing/>
<composing/> User is composing a message. User interacts with a message input interface specific to this chat session (e.g., types in the input area of a chat window). <active/>, <paused/>
<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. <active/>, <composing/>, <inactive/>
<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. <active/>, <gone/>
<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). <active/>

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 one-to-one chat session between a User and Contact (e.g., as specified in Chat Session Negotiation [4]) or explicit discovery by the User of the Contact's capabilities (e.g., as gained through Service Discovery [5] or Entity Capabilities [6]), 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 content message sent to the Contact MUST contain a chat state notification extension, which SHOULD be <active/>.
  2. Until receiving a reply to the initial content message (or a standalone notification) from the Contact, the User MUST NOT send subsequent chat state notifications to the Contact.
  3. If the Contact replies to the initial content 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 content message and includes an <active/> notification (or sends a standalone notification to the User), the User and Contact SHOULD send subsequent notifications for supported chat states (as specified in the next subsection) by including an <active/> notification in each content message and sending standalone notifications for the chat states they support (at a minimum, the <composing/> state).

The foregoing rules imply that the sending of chat state notifications is bidirectional (i.e., both User and Contact will either send or not send chat state notifications) rather than unidirectional (i.e., one of the conversation partners will send chat state notifications but the other will not); this is intentional.

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 standalone <composing/> notification in a row. More generally, a client MUST NOT send a second instance of any given standalone notification (i.e., a standalone notification MUST be followed by a different state, not repetition of the same state). However, every content message SHOULD contain an <active/> notification.

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 content messages and standalone notifications SHOULD be set to a value of "chat" (for one-to-one sessions) or "groupchat" (for many-to-many sessions).
  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

Chat state notifications MAY be sent in the context of groupchat rooms (e.g., as defined in Multi-User Chat [7]). The following business rules apply:

  1. A client MAY send chat state notifications even if not all room occupants do so.
  2. A client SHOULD NOT generate <gone/> notifications.
  3. A client 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 [8] 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 notification 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 [9] or HTTP Binding [10]) and services that rebroadcast message stanzas (e.g., Multi-User Chat services) MAY process standalone notifications differently from other messages. In particular, a server or service MAY refuse to deliver standalone 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 Content 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 Content Message Reply With <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 Standalone <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 Content Message 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 Content 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 content message and her client includes a notification that her state is <active/>:

Example 6. Contact's Client Sends Content Message Reply With <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 Standalone <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 Standalone <paused/> 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 Standalone <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 Content 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 Standalone <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 Standalone <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 Content 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 Standalone <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 Content 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 Content 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) [11].

10. Jabber Registrar Considerations

10.1 Protocol Namespaces

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

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

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

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

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

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

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

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

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

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

12. 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.14 (2005-07-20)

Clarified terminology; specified suggested state changes; removed section on superseding JEP-0022. (psa)

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