Links may not function; however, this content may be relevant to outdated versions of the product.
Tracking the online presence of operators
You can track the real-time connection status of operators so that you can route work to operators who are online and available. You can configure your Pega 7 Platform application to notify you when the online status of an operator changes, instead of repeatedly requesting the status.
When an operator logs in to an application, the Pega 7 Platform begins tracking the status of the requestor in the operator presence record, which maintains operator state information until the operator logs out of all sessions.
By default, each presence record captures operator status and connection information by using the following standard attributes. You use the PresenceService() API to configure these attributes.
- Operator ID – Operator ID.
- Operator_Name – Operator name.
- State – Connection status of the operator. The values for this attribute are:
- ACTIVE – The operator is currently logged in to the system.
- AWAY – The operator session has timed out.
- DISCONNECTED – The operator has been disconnected from the network because of one of the following events:
- The operator closed the browser session without logging out of the system.
- The operator browser session crashed.
- The network connection is down.
The operator status becomes ACTIVE when the network connection is restored or when the browser session is restored by the operator.
The operator status of DISCONNECTED is available beginning with Pega 7.3.
- OFFLINE – The operator is logged out of the system.
- Status – Current status of the operator, for example, "busy" or "do not disturb”. This attribute has no default value. You can update it by using the PresenceService() API.
- Geolocation – Current geographical coordinates of the operator. You can update this attribute by using the PresenceService() API.
- Sessions – List of sessions to which the operator is logged in.
To receive real-time notifications when the status information in the operator presence record changes, do one of the following actions:
- Subscribe to the Operator Presence channel. The operator presence record sends status notifications to this system-defined channel. The communication between this channel and subscribers is based on the publish/subscribe (pub/sub) messaging pattern. For more information about pub/sub implementation in the Pega 7 Platform, see Real-time applications and push notifications in the Pega 7 Platform.
- Use the PresenceService() API to query the presence record directly.
Receiving real-time status notifications by subscribing to a channel
- Optional: Define a category for custom operator record attributes. For example, you can add the custom operator statuses “Available on phone” and “In a meeting” to the standard status attributes.
- Use the setAttribute() method of the PresenceService() API to define your custom category and attributes. For more information, refer to the API documentation.
- Add the custom category to the Operator Presence channel.
- Click .
- Click the Gear icon next to the Operator Presence channel.
- Click Add category, and enter the category name.
- Click Submit.
- Configure your application component to subscribe to the channel.
- Locate the dynamic layout that displays the operator information, such as the team gadget or the messaging app window.
- Select the layout, and click the Gear icon to open the layout properties panel.
- Click Actions.
- Click Create an action set.
- Click Add an event, and select On load under Other events.
- Under Subscribe, select Operator Presence from the Channel name list.
- Select a category.
- Select the source of the operators list.
- Operators list – Select this option to add the list of operators manually.
- Clipboard page – Select this option if the list of operators is available on a clipboard page.
- Data page – Select this option if the list of operators is sourced from a data page.
- Click Add an action for callback to select the operation to be performed after receiving the updates.
When the status information for an operator is updated, the changes are automatically published to the Operator Presence channel. The channel broadcasts these updates to all subscribed application components. When subscribers receive these notifications, defined callback actions, such as running a specific activity, are automatically triggered to reflect operator real-time availability.
Querying directly to retrieve operator status
You can directly query the presence record to obtain on-demand status information, such as listing users within a particular location, by using the queryPresence() method of the PresenceService() API.
For example, to retrieve a list of operators whose status is “ACTIVE”, who can speak “French,” and whose status is not “AWAY", you can build three different clauses for each of these conditions. You join the clauses as shown in the following example:
PresenceQueryClause c1= PresenceQueryClause.Builder.createEqualsClause('A', PresenceQueryClause.STANDARD_CATEGORY, PresenceStandardAttributes.STATE.getName(), "ACTIVE", false);
PresenceQueryClause c2 = PresenceQueryClause.Builder.createEqualsClause('B',"CustomerService", "languages" , "French", false);
PresenceQueryClause c3 = PresenceQueryClause.Builder.createContainsClause('C', "CustomerService", "phone/status" , "AWAY", true);
List<PresenceRecord> records = tools.getPresenceService().queryPresence("A AND B AND C", Arrays.asList(c1,c2,c3), "CustomerService");
FetchUsersPresenceByState
activity Java code.When you use the API to query or update status, you can convert the results to a JSON object by using the PresenceRecord.toJson() method.
Updating status and other attributes on demand
Update the status, location, and other custom attributes of an operator on demand with the tools.getPresenceService().setAttributes() method of the PresenceService() API.
For example, to update the status and other custom attributes of an operator called [email protected], invoke the API as described in the following example to set the status standard attribute and the language and phone/status custom attributes:
//prepare arguments to pass
HashMap<String,String> standardAttributes = new HashMap<>();
standardAttributes.put(PresenceStandardAttributes.STATUS.getName() , "Office");
HashMap<String,String> customAttributes = new HashMap<>();
customAttributes.put( "languages", "French");
customAttributes.put( "phone/status", "Available");
//invoke API
boolean status=false;
try{
status = tools.getPresenceService().setAttributes("[email protected]", "CustomerService", customAttributes, standardAttributes);
} catch(PresenceException e){
//TODO
}
return status;
modifyUserPresenceAttributes
activity Java code to view sample queries.Changing the default interval delay timing for operator disconnect status
A client heartbeat mechanism polls web socket connections to monitor the connection status of operators. The following prconfig.xml file settings control polling frequency and client heartbeat threshold:
server-push/client-heartbeat/interval
– Default value is 20 seconds.operatorpresence/max-client-heartbeats-missable
– Default minimum value is 2 heartbeats.
To reduce the interval delay timing for updating the operator disconnect status in the event of a network disconnection or browser crash, change the default values of these settings in the prconfig.xml file. If you update these settings, you must restart your system for the settings to take effect.