Work with Enhanced Presence Using Unified Communications AJAX Service API
This documentation is archived and is not being maintained.

Work with Enhanced Presence Using Unified Communications AJAX Service API

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The AJAX Service API supports publication and subscription of enhanced presence.

To publish the presence information, an AJAX API client sends, through the command channel, a request containing relevant presence category instances. A request in AJAX API is embodied in a <cwaRequests> element and contains one or more <cwaCateogry> elements to hold specified presence data. The following example shows a request to publish a presence note.

<cwaRequests sid="123" xmlns = "">
  <publishSelfPresence rid="2">
   <cwaCategory name="note" instanceMask="0" expires="-1">
      <note xmlns="">
         <body type="personal">This is a personal note</body>

In the example above, the <publishSelfPresence> element describes the command of the request. This and the other two elements, <cwaRequest> and <cwaCateogry>, are defined by the AJAX API. The <note> element, however, is defined by the Enhanced Presence Schemas described in this document.

To subscribe to the presence information of a specified user, an AJAX API client registers for event notifications to receive and handle the userPresence events from the event channel. The userPresence event is described by an <userPresence> element, which is enveloped within a <cwaEvents> element. The event element contains a user element (<user>) and one or more <cwaCategory> elements. Each <cwaCategory> element in turn contains one or more enhanced presence elements describing the user's presence information, including the user state (<state>), note (<note>), contact information (<contactCard>), and others. Here, the <cwaEvents>, <userPresence>, and <user> elements are all defined by the AJAX Service API. As with the case of the presence publication discussed above, the child elements of a <cwaCategory> element are of the Enhanced Presence Schemas elements. The following event example returns the presence state, note, and a contact card of a user (

   <userPresence eid="10">
      <user uri="" sourceNetwork="sameEnterprise">
         <cwaCategory name="state" instance="0">
            <state xmlns=".../sip/state" 
               <activity token="Offline" />

         <cwaCategory name="note" instance="0">
            <note xmlns=".../sip/note">
               <body type="personal" />

         <cwaCategory name="contactCard" instance="0">
            <contactCard xmlns=".../sip/contactcard">
                     <displayName>Jay A.</displayName>


To receive the self presence information, an AJAX API client needs to handle the <selfPresence> events. The programming pattern is similar to handling the <userPresence> events.

Unified Communications AJAX Service API also supports publishing and receiving custom presence information. For more information, see the Unified Communications AJAX 2007 SDK documentation.

© 2016 Microsoft