---
sourceDocument: Xanadu ServiceNow AI Platform Capabilities
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/servicenow-platform

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Capabilities

ft:clusterId :

    - platcap

bundleId :

    - platcap

workflow :

    - Platform


---

# Tutorial: Route interactions by context

# Tutorial: Route interactions by context {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

Learn how you can configure Advanced Work Assignment to route conversations
to agents according to the context of the conversation.
Activate the Customer Service Management Demo Data (com.snc.customerservice.demo) plugin.

A basic understanding of context variables is required. For more information on context
variables, see [Virtual Agent scripts](https://www.servicenow.com/docs/access?context=virtual-agent-scripts&version=xanadu&pubname=xanadu-conversational-interfaces&ft:locale=en-US).  
The What can we help you with? record producer is available by default with the Customer Service Management Demo Data (com.snc.customerservice.demo) plugin. In the record producer, chat requesters can specify one of three issue categories that they need help with:

* Product
* Billing
* Order
{#context-routing-tutorial__ul_bq1_wvb_zhb}

Whichever category they select passes a value through the <var class="keyword varname">liveagent_csp_category</var> context variable. Learn how to create queues that route conversations to agents according to the values passed through this
context variable.

## Create a queue for product issues {#ariaid-title2}

Create a queue for the Chat service channel that routes product issues.

### Before you begin

Role required: awa_admin or admin

### Procedure

1. Navigate to the queue settings through one of the following navigation paths:
   * AllAdvanced Work AssignmentHome.

     In the Essential settings section, select Set up queues.
   * AllAdvanced Work AssignmentQueues.
   {#product-context-example__choices_nt4_2f3_tvb}
2. Select New.
3. Enter the following information in the fields listed:  
   * Name: Product Support
   * Service channel: Chat
   * Condition mode: Advanced
   {#product-context-example__ul_wcw_lm4_dhb}
4. In the Script field, enter this script:  

       (function executeCondition(/* glide record */ current) {  
       	var contextTable = current.getValue('context_table');
       	var interactionBlobRecord = new GlideRecord(contextTable);
       	interactionBlobRecord.addQuery('sys_id',current.getValue('context_document'));
       	interactionBlobRecord.query();

       	if(interactionBlobRecord.next()){
       		var jsonBlob = JSON.parse(interactionBlobRecord.getValue('value'));
       		if(jsonBlob.liveagent_csp_category == 'product')
       			return true;
       	}
       	return false;
       })(current);

5. Click Submit.

## Create a queue for billing issues {#ariaid-title3}

Create a queue for the Chat service channel that routes billing issues.

### Before you begin

Role required: awa_admin or admin

### Procedure

1. From the Queues list view, click New.
2. Enter the following information in the fields listed:  
   * Name: Billing Support
   * Service channel: Chat
   * Condition mode: Advanced
   {#billing-context-example__ul_hjh_xm4_dhb}
3. In the Script field, enter this script:  

       (function executeCondition(/* glide record */ current) {  
       	var contextTable = current.getValue('context_table');
       	var interactionBlobRecord = new GlideRecord(contextTable);
       	interactionBlobRecord.addQuery('sys_id',current.getValue('context_document'));
       	interactionBlobRecord.query();

       	if(interactionBlobRecord.next()){
       		var jsonBlob = JSON.parse(interactionBlobRecord.getValue('value'));
       		if(jsonBlob.liveagent_csp_category == 'billing')
       			return true;
       	}
       	return false;
       })(current);

4. Click Submit.

## Create a queue for order issues {#ariaid-title4}

Create a queue for the Chat service channel that routes order issues.

### Before you begin

Role required: awa_admin or admin

### Procedure

1. From the Queues list view, click New.
2. Enter the following information in the fields listed:  
   * Name: Order Support
   * Service channel: Chat
   * Condition mode: Advanced
   {#order-context-example__ul_cjz_hn4_dhb}
3. In the Script field, enter this script:  

       (function executeCondition(/* glide record */ current) {  
       	var contextTable = current.getValue('context_table');
       	var interactionBlobRecord = new GlideRecord(contextTable);
       	interactionBlobRecord.addQuery('sys_id',current.getValue('context_document'));
       	interactionBlobRecord.query();

       	if(interactionBlobRecord.next()){
       		var jsonBlob = JSON.parse(interactionBlobRecord.getValue('value'));
       		if(jsonBlob.liveagent_csp_category == 'order')
       			return true;
       	}
       	return false;
       })(current);

4. Click Submit.

*[\>]: and then


