cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1297
Views
5
Helpful
5
Replies

Area Code routing in UCCX script

alexgrinberg
Level 1
Level 1

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

5 Replies 5

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

Jonathan Schulenberg
Hall of Fame
Hall of Fame

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:

  • http://localcallingguide.com/lca_listnpa.php
  • https://www.nationalnanpa.com/reports/reports_npa.html

Excellent Guide, here's an example script finding the area code and doing the XML file lookup.

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

If you just want to know if it's Canada, or US, or niether - then
couldn't you just create a comma-separated string of all the Canada area
codes, and another of all US area codes?  Then just use a simple IF
statemet to check if the Canada-string *contains *the caller's area code
(or if index-of(areaCode)>=0)
If not, check if the US-string contains the caller's area code?
Since it's always 3-digits, then you need not worry about lookups or
substrings.

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: