cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
230
Views
15
Helpful
7
Replies
Beginner

UCCX and XML Get Data

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

Re: UCCX and XML Get Data

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.


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
7 REPLIES 7
Highlighted
Enthusiast

Re: UCCX and XML Get Data

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

Re: UCCX and XML Get Data

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

VIP Advisor

Re: UCCX and XML Get Data

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

 


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Beginner

Re: UCCX and XML Get Data

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

VIP Advisor

Re: UCCX and XML Get Data

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.


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Beginner

Re: UCCX and XML Get Data

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

 

Brian  

VIP Advisor

Re: UCCX and XML Get Data

Awesome! You're welcome!

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards