Tutorial: Route interactions by context

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 2 minutes to read
  • Learn how you can configure Advanced Work Assignment to route conversations to agents according to the context of the conversation.

    Before you begin

    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.

    Role required: awa_admin or admin

    About this task

    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

    Whichever category they select passes a value through the liveagent_csp_category 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

    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:
      • All > Advanced Work Assignment > Home.

        In the Essential settings section, select Set up queues.

      • All > Advanced Work Assignment > Queues.
    2. Select New.
    3. Enter the following information in the fields listed:
      • Name: Product Support
      • Service channel: Chat
      • Condition mode: Advanced
    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

    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
    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

    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
    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.