06-24-2019 08:12 AM
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!
Solved! Go to Solution.
06-25-2019 08:52 AM
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.
06-24-2019 11:28 AM
06-25-2019 04:01 AM
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
06-24-2019 02:41 PM - edited 06-24-2019 02:48 PM
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
06-25-2019 04:55 AM
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
06-25-2019 08:52 AM
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.
06-26-2019 07:19 AM
That is exactly what I was looking for. I've modified my configurations and it works great. Thank-you!
Brian
06-26-2019 01:48 PM
06-21-2022 12:08 PM
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()"
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.
06-21-2022 07:22 PM
06-22-2022 09:09 AM
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.
Seems the value for triggeringContactAreaCode is not concatenated in the XPath
06-22-2022 09:46 AM
06-22-2022 04:01 PM
I get the value "306" when i check the debug. Please see below:
06-22-2022 06:37 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide