Newer Version Available
Step 4: Create AgentWork
Your partner application must create an AgentWork record to route
the work to an agent in Omni-Channel.
When the external routing implementation receives new PendingServiceRouting creation events (where the routing type equals External), it uses the standard Salesforce SOAP API to fetch further information based on the PendingServiceRouting. It makes a routing decision by creating AgentWork records. This API is existing functionality that partners use to query Salesforce.
Reference the following code sample to create AgentWork using
Apex.
1AgentWork work = new AgentWork();
2work.ServiceChannelId = '<ServiceChannelId>;
3work.WorkItemId = '<WorkItemId>';
4work.UserId = '<UserId>';
5work.PendingServiceRoutingId = '<PendingServiceRoutingId>';
6insert work;