07-07-2016 11:57 AM - edited 03-14-2019 04:19 PM
Hello,
I need suggestion of the best way to route the calls base on Area Code in UCCX script. I need to build the script that can validate the area code and if this is US area code send call to US queue and if this is Canada area code to send call to Canada queue, and if no area code recognized send it to the menu and ask if the caller from US or Canada.
My script is reading the area code and send it to sub flow to check in XML file first if this is Canada and if not send it to second sub flow and check in XML file if this is US. This is working but I am worry that list of US Area Codes is very long list and takes about 300 steps.
Is some one can suggest the better way to set it up.
Thank you
07-07-2016 02:10 PM
I've not checked this, but is there a range you can collapse this into? Like 200-299 = USA, which would reduce your steps.
I've seen pretty big scripts, I really don't think 300 steps is bad, but any optimization now will save you headaches tomorrow.
david
07-09-2016 11:55 AM
This is where XPath comes to your rescue. You can create an XML document, or perhaps use the one you already have depending on the structure, and then have the CCX script query the XML file in a single step. No need to loop through every row in the XML file.
Example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nanp_npa_assignments>
<npa uid="404">us</npa>
<npa uid="608">us</npa>
<npa uid="416">ca</npa>
<!-- etcetera -->
</nanp_npa_assignments>
In the AEF script, just use a Get XML Document Data step with a properly structured XPath statement. Continuing the example:
"/nanp_npa_assignments/npa[@uid='" + triggeringContactAreaCode + "']/"
which will be concatenated at runtime to look like this:
/nanp_npa_assignments/npa[@uid='404']/
Take note of the combination of a single and double quote here. The double quote is part of the String concatenation while the single quote is part of the XPath statement.
The variable triggeringContactAreaCode is the NPA you have parsed out of the ANI using some other method such as a nested if statement based on the leading character and length. Example:
if ((triggeringContactCallingNumber.length() == 12) && ((triggeringContactCallingNumber.startsWith("+1")) || (triggeringContactCallingNumber.startsWith("91")))) {
triggeringContactAreaCode = triggeringContactCallingNumber.substring(2,5);
else if ((triggeringContactCallingNumber.length() == 11) && (triggeringContactCallingNumber.startsWith("1"))) {
triggeringContactAreaCode = triggeringContactCallingNumber.substring(1,4);
} else if (triggeringContactCallingNumber.length() == 10) {
triggeringContactAreaCode = triggeringContactCallingNumber.substring(0,3);
} else {
triggeringContactAreaCode = "";
}
If the area code is not found then the result variable of the Get XML Document Data step will be given a null value. At that point you can use a Switch step (aka Match Case) to decide how to proceed:
Match Switch (nanpNpaAssignmentResult.toLowerCase()) {
Case: "us"
// US caller logic
Case: "ca"
// CA caller logic
Case: Default
// Unknown caller logic - play a menu
Finally, you can get a list of the active area codes here:
05-17-2022 07:53 AM
05-17-2022 08:29 AM
Another cool way specially if you're looking to know carrier or if it's a mobile number would be to do it via API using something like https://numverify.com/. There is a cost though, but looks very easy to use.
david
05-17-2022 08:34 AM
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: