Enable Analytics-Based Text Routing
Required permissions: Scripts Create/Edit
You can use the CXone analytics-based text routing service to analyze incoming text interactions and determine routing procedure based on things like the dataset of the interaction, priority, sentiment Overall mood or result of the interaction as determined by analysis of words, phrases, and context of the transcript. 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.
Before performing the following steps, be sure to register Interaction Analytics with CXone to receive a client_secret and client_id. You must include these in CXone API calls. Follow the registration and authentication process explained on the developer portal.
- In your routing script, add a Snippet action.
- Double-click the Snippet and add a text-based routing script.
Click to view an example script:
//These are the three steps to utilize analytics-based text routing: //1 - Authenticate against the API to generate a token //2 - Perform the annotation call to get analytics results //3 - Parse out custom logic from results for routing or other purposes //Step 1 - Authenticate against NICE CXone API to generate a token
//Create a Rest Proxy
ASSIGN authProxy=GetRESTProxy()
authProxy.ContentType="application/json"
//This URL is for the authentication and shouldn't change.
ASSIGN authURL="https://cxone.niceincontact.com/auth/token"
//Add the OAuth 2.0 Authorization that is unique to your account.
//For information on creating an authorization key, see documentation in Developer Portal for Getting Started.
//Replace {TOKEN HERE} with authorization key.
authProxy.AddHeader("Authorization","basic {TOKEN HERE}")
//Create a Dynamic Data Object with the OAuth Credentials of a NICE CXone 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 CXone for the Analytics API
ASSIGN restURL="https://analytics.incontact.com/studio-gateway/annotate"
proxy.ContentType="application/json"
//Utilize the token variable that came from the previous API call
proxy.AddHeader("Authorization","bearer {token}")
//Prepare the text that will be sent to the Analytics service to be annotated.
//In this example we used "Where is my shipment?"
DYNAMIC textToAnnotate
textToAnnotate.text="Where is my shipment?"
//textToAnnotate.text={somePreviousVariable} //This alternative line shows an example
//utilizing a variable for the text. You do not need both lines.
ASSIGN body="{textToAnnotate.asJSON()}"
//The response will include sentiment, language, categories, frustration among others.
//There is no need to change the parameters that are passed into this REST API call.
ASSIGN result=proxy.MakeRestRequest(restURL, body, 0, "Post")
//Step 3 - Custom logic for routing or other purposes.
//The sentiment, language, frustration and categories variables below are pulled from the result.
ASSIGN sentiment=result.documentSentiment
ASSIGN language=result.language
ASSIGN customerFrustration=result.frustration.frustrationType
ASSIGN categories=result.categories
ASSIGN categoryCount = categories.count()
//Now we can use logic based on the results for categories, sentiment, frustration,
//language, etc for assigning skills or other routing purposes.//This is just one example; the logic should be constructed to suit the need.
IF language = "english" {
IF customerFrustration = "HIGH" && sentiment = "NEGATIVE"
{
ASSIGN SkillNo=123456 //Example text: "I'm very frustrated."
}
ELSE
{
IF categoryCount > 0
{
//Cycle through categories to see if there are matches to categories of interest.
//In this example, we are looking for a Shipping contact purpose.
ASSIGN SkillNo = 123457 //Default skill in the case of categories but none of interest.
FOR i = 1 TO categoryCount
{
IF categories[i].categoryPath = "Contact Purpose/Transaction/Shipping"
{
ASSIGN SkillNo=123458 //Example text: "Where is my shipment?"
}
}
}
ELSE
{
ASSIGN SkillNo=123457 //Example text: "Nothing to see here."
}
}
}
ELSE
{
ASSIGN SkillNo=123459 //Example text: "Yo estoy aqui."
}