Understand the Details of the Routing Lifecycle in omni channel salesforce
When you dig more deeply into Omni-Channel and the routing process, there are two particular objects that are worth understanding better: PendingServiceRouting (PSR) and AgentWork.
What Is PSR? What Is AgentWork?
PSR (PendingServiceRouting) is a Salesforce object that gets created when work is routed using Omni-Channel. PSR is a transient object that contains routing information about a work item that is in the midst of being routed. In most scenarios, the system automatically creates the object; in a few scenarios (like when using skills-based routing with non-real-time channels), you must create this object. The PSR is deleted by the system when an agent accepts the work item.
AgentWork is a Salesforce object that automatically gets created when the routing system finds a potential agent to handle the work item. It contains information about the work item and the routing status. This object is never automatically deleted, but you can manually delete it when the State field is in a non-active state. (Active states are Assigned and Opened. All other states are considered non-active states.)
Why Should I Care?
When you’re using skills-based routing (SBR) with non-real-time channels, you must manually create the PSR record to initiate the routing process.
In queue-based routing or skills-based routing using a real-time channel (like Messaging and Chat), the PSR record is created automatically. However, you still may want to access this object for more complex use cases or for troubleshooting.
What Is the Basic Lifecycle?
In the simplest scenario, a PSR record is created when a work item is routed using Omni-Channel. When the system finds a potential agent to handle the work item, an AgentWork record is created. When an agent accepts the work item, the system deletes the PSR record. The AgentWork record is never deleted automatically by the system, but it can be deleted manually when it enters a non-active state (such as Closed, Unavailable, Declined, Canceled, Transferred).
What Is the Detailed PSR and AgentWork Lifecycle?
To fully understand the lifecycle of these two objects, refer to this state diagram. In addition to the creation and deletion of PSR and AgentWork records, this diagram describes the PSR.IsPushed
state and the AgentWork.Status
value in different phases of the lifecycle.
The PSR record is transient whereas the AgentWork record sticks around until it’s explicitly deleted.
Why does AgentWork contain multiple work records for the same work?
Each time a work item is assigned to an agent, a record is created in AgentWork. For example, if an agent transfers a work item to another agent, two records exist–one for each agent. If the work is assigned to a new agent but the original agent keeps the work open, AgentWork contains multiple active records for the work item–one for each agent. AgentWork can have multiple work records for the same agent and work item if the work item is routed to the same agent multiple times.
When is the AgentWork record set to Closed?
An AgentWork record isn’t closed until one of these events happens.
- For tab-based capacity, a record closes when the assigned agent closes the work tab in the Service console.
- For status-based capacity, the record closes when the work has a completed status or the work is reassigned.
- If After Conversation Work is enabled, the work closes if the After Conversation Work period ends.
Why isn’t a work item in a queue assigned to an agent in Omni-Channel?
Work isn’t assigned to an agent if the queue doesn’t have a routing configuration. Without a routing configuration assigned to the queue, Omni-Channel doesn’t route work items in the queue.
The PSR record is transient whereas the AgentWork record sticks around until it’s explicitly deleted.
Why does AgentWork contain multiple work records for the same work?
Each time a work item is assigned to an agent, a record is created in AgentWork. For example, if an agent transfers a work item to another agent, two records exist–one for each agent. If the work is assigned to a new agent but the original agent keeps the work open, AgentWork contains multiple active records for the work item–one for each agent. AgentWork can have multiple work records for the same agent and work item if the work item is routed to the same agent multiple times.
When is the AgentWork record set to Closed?
An AgentWork record isn’t closed until one of these events happens.
- For tab-based capacity, a record closes when the assigned agent closes the work tab in the Service console.
- For status-based capacity, the record closes when the work has a completed status or the work is reassigned.
- If After Conversation Work is enabled, the work closes if the After Conversation Work period ends.
Why isn’t a work item in a queue assigned to an agent in Omni-Channel?
Work isn’t assigned to an agent if the queue doesn’t have a routing configuration. Without a routing configuration assigned to the queue, Omni-Channel doesn’t route work items in the queue.