logo

NJP

Advanced Work Assignment: (Un)Set Agent's Availability automatically

Import · Jan 29, 2022 · article

image

Tracking the Agent's Availability

The current state of an agent is tracked at table awa_agent_presence:

image

For users with the roles "awa_manager", "awa_admin" and of course "admin" the value at column "Current presence state" can be changed to "Available" manually. This might be necessary in case an agent with open chat sessions suddenly fails and the service desk manager needs to kick that agent out manually.

Set Agent's State to "Available" automatically

Option (1): During Login

To react on a login action, we can "catch" the change of the field "Last login time" at table sys_user.

For this purpose, we just have to implement the following business rule:

Table sys_user
Advanced true
When async
Update true
Filter Conditions image
Condition gs.tableExists('awa_agent_presence') && gs.hasRole('awa_agent')
Script (function executeRule(current, previous) { var grPresence = new GlideRecord("awa_agent_presence"); if (!grPresence.get("agent", current.getUniqueValue())) { grPresence.initialize(); } grPresence.setDisplayValue("current_presence_state", "Available"); grPresence.update(); })(current, previous);

After the next login, the presence state at the Workspace Inbox should display "Available" as well as the assigned Service Channels:

image

Option (2): First usage of the Agent Workspace

The underlying argument for this approach is that agents may be performing other activities in the system before opening a workspace and being ready for their work.

But it is not easy to identify such an event and the only way I could figure out so far is watching the Transaction Log table. After some tests, a good "candidate" seems to be the URL /api/now/awa/presence_query_history/create_or_update?api=api

image

If you really want to react on the URL, you could implement a Business Rule (I suggest "async" as type) on table syslog_transaction.

However, I can't really recommend this, as the Transaction Log table is one of the most frequented tables and any additional business logic may have performance implications.

Set Agent's State to "Offline" automatically

Basically there is no need to configure/script anything as there is a Scheduled Script "AWA - Set Inactive Agents Offline" which runs each minute and checks whether the agent is still subscribed to the AMB inbox channel. If not, it sets the presence state accordingly:

image

If you want to reduce the time between two runs, it is not enough to modify the value at field "Repeat interval". You also have to set the system property com.glide.awa.agent_inactivity_threshold_seconds accordingly. That property is set to "60" (seconds) per default.

For an even more timely response in case the agent has logged out explicitly, you also could implement another Script Action which reacts on the "logout" event:

image

Labels:

image

View original source

https://www.servicenow.com/community/csm-articles/advanced-work-assignment-un-set-agent-s-availability/ta-p/2297079