Enable Analytics-based Text Routing

Required security profile permissions: Scripts Create/Edit

You can use NICE inContact's Analytics-based Text Routing service to analyze incoming text interactions and determine routing procedure based on things like the topic of the interaction, priority, sentimentThe overall mood of the contact, or the result of the call as determined by analysis of words, phrases, and context of the transcript. An interaction can be positive (blue), negative (red), mixed (dark gray), or neutral (light gray). analysis, the language of the text, or a combination of these factors.

The text must be sent to the routing service for analysis, then the service returns annotated information that can be used to route the interaction to the appropriately skilled agent.

  1. In your routing script, add a SNIPPET action.

  2. In the SNIPPET action add a text-based routing script, such as this sample:

    ASSIGN proxy=GetRESTProxy()

    //Utilize the URL provided by NICE inContact for the Sentiment API

    ASSIGN restURL="https://analytics.inuncn.com/studio-gateway/annotate"

     

    //These are the three steps to utilize sentiment based routing:

    //1 - Authenticate against the API

    //2 - Perform the annotation call to get sentiment details

    //3 - Parse out custom logic from results for routing or other purposes.

     

    //Step 1 - Authenticate against NICE inContact API

    //Create a Rest Proxy

    ASSIGN authProxy=GetRESTProxy()

    authProxy.ContentType="application/json"

    //Add the OAuth 2.0 Authorization that is unique to your account. 

    //This comes FROM the API Application built IN Central.  Replace {TOKEN HERE} With Auth Key.

    authProxy.AddHeader("Authorization","basic {TOKEN HERE}")

    //This URL is for the Authentication and shouldn't change.

    ASSIGN authURL="api.incontact.com/InContactAuthorizationServer/Token"

    //Create a Dynamic Data Object with the OAuth Credentials of a NICE inContact User with API Access.

    DYNAMIC creds

    creds.scope=""

    creds.password="" //Populate your user's password here

    creds.grant_type="Password"

    creds.username="" //Populate your user's username here

    ASSIGN credsAsJSON="{creds.asJSON()}"

    //Perform REST API Call against Auth Server

    //There is no need to change the parameters that are passed into this REST API call

    ASSIGN authResult=authProxy.MakeRestRequest(authURL, credsAsJSON, 0, 'Post')

    ASSIGN token=authResult.access_token

     

    //Step 2 - Perform API Call to receive sentiment based results

    //Create a new Proxy

    ASSIGN proxy=GetRESTProxy()

    //Utilize the URL provided by NICE inContact for the Sentiment API

    ASSIGN restURL=""

    proxy.ContentType="application/json"

    //Utilize the token variable that came from the previous API call

    proxy.AddHeader("Authorization","bearer {token}")

    //In your params pass the text that should be utilized for review. In this example we used "where is my shipment?"

    ASSIGN params="{char(123)}{char(34)}text{char(34)}:{char(34)}Where is my shipment?{char(34)}{char(125)}"

    //This next line is the same as the one above but shows an example utilizing a varaible for the text.

    //You do not need both of these, just the one that fits your scripting need.

    ASSIGN params="{char(123)}{char(34)}text{char(34)}:{char(34)}{somePreviousVariable}{char(34)}{char(125)}"

    //The response will include sentiment, language, categories amongst others.

    //There is no need to change the parameters that are passed into this REST API call

    ASSIGN result=proxy.MakeRestRequest(restURL, params, 0, "Post")

    //The sentiment, language, and categories variables below are pulled from the result.

    ASSIGN sentiment=result.documentSentiment

    ASSIGN language=result.language

    ASSIGN categories=result.categories

     

    //Step 3 - Custom logic for routing or other purposes.

    //Cycle through the Categories.  In this example it's hard coded to three but you may want to adjust this to be dynamic.

    ASSIGN categoryCount = 3

    FOR i = 1 TO categoryCount

    {

           ASSIGN categoryPath = categories[i].categoryPath

           //In this example, we are looking for a Shipping Purpose.  This way we can route to shipping.

           //Your logic here can be custom for and category that is configured and you see fit for routing.

           IF categoryPath = "Contact Purpose/Transaction/Shipping"

           {

                  ASSIGN category = categories[i].categoryName

           }

    }

     

    //Now that you have Sentiment and Language, you can write custom logic for assigning skills or other routing purposes

    IF sentiment = "NEGATIVE"

    {

      IF language = "english"

      {

        ASSIGN SkillNo=123456

      }

      ELSE

      {

        ASSIGN SkillNo=123457

      }

    }

    ELSE

    {

      ASSIGN SkillNo=123458

    }