cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2417
Views
15
Helpful
13
Replies

UCCX and XML Get Data

BKarv246
Level 1
Level 1

Hello,

 

Currently working with UCCX 10.6 as an IPIVR.  I have created a script in UCCX to route callers based on their area code and all functions as it should.  I have written an XML referencing the area codes as shown in this example format:

<?xml version="1.0" encoding="utf-8"?>
<AreaCodeList>
     <AreaCode ID="123">
          <Agent>1</Agent>
     </AreaCode>
     <AreaCode ID="456">
          <Agent>1</Agent>
     </AreaCode>
     <AreaCode ID="789">
          <Agent>1</Agent>
     </AreaCode>
     <AreaCode ID="987">
          <Agent>1</Agent>
     </AreaCode>
     <AreaCode ID="654">
          <Agent>2</Agent>
     </AreaCode>
     <AreaCode ID="321">
          <Agent>2</Agent>
     </AreaCode>
</AreaCodeList>

 

As you can see in the example multiple area codes will route to the same agent.  Is there a way in XML to condense what I have listed above?

 

Thank-you for your input!

1 Accepted Solution

Accepted Solutions

That's fair. XML is widely used in UCCX scripting.

 

Another option to condense your XML data is to put your area codes in a comma separated list within the same XML element, and use the "contains" predicate selector of XPath to check the list.

 

Example:

---XML Document---
<Agents>
  <Agent ID="1">100,101,102,...</Agent>
  <Agent ID="2">500,501,502,...</Agent>
</Agents>

---XPath---
"//Agent[contains(., '" + area_code + "')]/@ID"

 

Also, I see you're on 10.6, so this wouldn't apply to you right now, but in 11.6(1) the script editor can now also understand JSON.

 

In my opinion, its main benefit is that it's less verbose than XML.

 

Example:

 

---JSON Document---
[
  {
    "id": "agent1",
    "areacodes": ["100", "101", "102", ...]
  },
  {
    "id": "agent2",
    "areacodes": ["500", "501", "502", ...]
  }
]

---JSONPath---
"$[?('" + area_code + "' in @.areacodes)].id"

 

*Note that according to the spec, an expression used in the JSONPath will always return a list.  Therefore, you must assign the results of the step Get JSON Document Data to a String Array.

View solution in original post

13 Replies 13

Mike_Brezicky
Cisco Employee
Cisco Employee
You will still need a row for each area code, but you can consolidate into a grouping such as below. Its not too much different though.

<?xml version="1.0" encoding="utf-8"?>
<AreaCodeList>
<AreaCode ID="123">1</AreaCode>
<AreaCode ID="456">1</AreaCode>
<AreaCode ID="654">2</AreaCode>
<AreaCode ID="321">2</AreaCode>
</AreaCodeList>

Th aef script will need adjusted appropriately to parse the file. This at least lets you not have to loop the file which is likely what is being done with your example.
Get XML Document Data (Agent, "/AreaCodeList/AreaCode[@ID='" + parsedAreaCode + "']/" assuming you are already capturing the parsed area code from the ANI.

Thank-you, Mike!  I was hoping all area codes could be grouped under a single statement for one agent somehow, but it looks like that's not possible with XML.  I do like the formatting you've posted better.  

 

Brian

Anthony Holloway
Cisco Employee
Cisco Employee

XML is a great data structure, but it may not always be the best fit.  Is this some reason you need to use XML for this?

 

Have you explored any alternative methods for mapping area codes to individuals?

 

Here's just one additional option for you to consider, and it's completely self contained within the scripting, using a variable type called a HashMap.  This kind of acts like a two column database table.

 

--- Variables ---
String target_agent = ""
java.util.HashMap area_codes = { java.util.HashMap map = new java.util.HashMap();
/* North East Region */ map.put("212", "Agent1"); map.put("320", "Agent1"); map.put("484", "Agent1"); map.put("...", "...");
/* South East Region */ map.put("305", "Agent2"); map.put("768", "Agent2"); map.put("515", "Agent2"); map.put("...", "...");
return map; } --- Script Steps --- If (area_codes.containsKey(area_code)) True Set target_agent = (String) area_codes.get(area_code)
Goto Area Code Known Routing False /* The area code for the caller is not in our map */
Goto Area Code Unknown Routing

 

Hi, Anthony.  I appreciate the response.  There is no particular reason why I have to use XML, just what I came across in most examples where area code based routing in UCCX was being performed. 

 

I am not familiar with HashMap and will have to do some exploring on how exactly to get things to work going this route.

 

Thanks again!

 

Brian

That's fair. XML is widely used in UCCX scripting.

 

Another option to condense your XML data is to put your area codes in a comma separated list within the same XML element, and use the "contains" predicate selector of XPath to check the list.

 

Example:

---XML Document---
<Agents>
  <Agent ID="1">100,101,102,...</Agent>
  <Agent ID="2">500,501,502,...</Agent>
</Agents>

---XPath---
"//Agent[contains(., '" + area_code + "')]/@ID"

 

Also, I see you're on 10.6, so this wouldn't apply to you right now, but in 11.6(1) the script editor can now also understand JSON.

 

In my opinion, its main benefit is that it's less verbose than XML.

 

Example:

 

---JSON Document---
[
  {
    "id": "agent1",
    "areacodes": ["100", "101", "102", ...]
  },
  {
    "id": "agent2",
    "areacodes": ["500", "501", "502", ...]
  }
]

---JSONPath---
"$[?('" + area_code + "' in @.areacodes)].id"

 

*Note that according to the spec, an expression used in the JSONPath will always return a list.  Therefore, you must assign the results of the step Get JSON Document Data to a String Array.

That is exactly what I was looking for.  I've modified my configurations and it works great.  Thank-you!

 

Brian  

Awesome! You're welcome!

Nicholas007
Level 1
Level 1

Hello, I am having some an issue with what I think is the XPath in my Script. I would appreciate is someone can point me in the right direction or what I am missing.

 

A: I am capturing the parsed area code from the ANI already in string variable called triggerContactAreaCode. This Works

B: I have my AreaCodeList XML: This works

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nanp_npa_assignments>
<npa uid="204">MB</npa>
<npa uid="431">MB</npa>
<npa uid="584">MB</npa>
<npa uid="306">SK</npa>
<npa uid="639">SK</npa>
<npa uid="474">SK</npa>
<npa uid="368">AB</npa>
<npa uid="403">AB</npa>
<npa uid="587">AB</npa>
<npa uid="780">AB</npa>
<npa uid="825">AB</npa>
<npa uid="833">TF</npa>
</nanp_npa_assignments>

C: I am capturing Xpath into string variable AreaCodeContactCalledNumber:  This does not work. I keep getting null value

            "/nanp_npa_assignments/npa[@uid='"+triggeringContactAreaCode+"']/text()"

Then I am using Switch:

     SK -----> Call Steps

     MB -----> Call Steps

     AB ------> Call Steps

     TF ------> Call Steps

 

Example:I debug the script, I get the triggerContactAreaCode value of 306, then XPATH step runs then I get a null value for AreaCodeContactCalledNumber instead of value SK.

 

 

Any chance the issue is with your quotes? This works just fine: /nanp_npa_assignments/npa[@uid="204"]/text()

 

david

Hi David,

 

I tried using

"/nanp_npa_assignments/npa[@uid="+triggeringContactAreaCode+"]/text()"

but still get null value

the triggeringContactAreaCode is my captured area code from ANI

Here is the new debug screen shot using "/nanp_npa_assignments/npa[@uid="+triggeringContactAreaCode+"]/text()"

Still got null value.

Capture1.JPGCapture2.JPG

Seems the value for triggeringContactAreaCode is not concatenated in the XPath

 

When you contact the area code, what does the final string look like?

 

david

I get the value "306" when i check the debug. Please see below:

 

Capture2.JPG

No, I'm asking to put the concatenated string (xpath) to a variable to see what the final string looks like before the xpath happens.

 

david

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: