Suggestion: Commercial Module (is it available) (area code routing)

Hi:

Is there a commercial module which would help with:

Routing incoming calls: based on area code
So that specific area codes go to specific IVR (auto attendants)

Right now, we can do this (sort of clunky), but our existing time conditions are sort-of getting in the way of making this an easy process.

Thanks for your thoughts.

No commercial module helps with this. You could use Dynamic Routes and branch call flow based on area code. To get the area code from the caller ID of a North American number, you would use the Asterisk function like this:

${CALLERID(number):-10,3)

The problem with this approach is that there are many area codes, and you would have to enumerate each in the dynamic route. To do this efficiently you would need an AGI or API that returned the correct destination based on the area code.

in addition to that, its not just the NPA that affects things.
the NXX can also be vastly different geographic regions.
(north American standard, 1-NPA-NXX-XXXX)

In the North America Numbering Plan the NPA is part of the geographic location. The NXX is the Rate Center. The XXXX is the user. 313 NPA means Wayne County Michigan while 734 is both Wayne and Washtenaw county as it was the NPA for the latter and expanded to an overlay in the former.

I parse CID’s with

It should work anywhere in the world, but be aware that US cell phone numbers will return only the state, land lines return the original office from which it was assigned, given number portability it just ‘best effort’

1 Like

(eew python).
Go / Golang master race!

Choose your language . . .

But I bet my python is shorter than your golang

#!/usr/bin/env python3
import sys
import phonenumbers
from phonenumbers import geocoder
print(geocoder.description_for_number(phonenumbers.parse(sys.argv[1], "US"), "us"),end='')
1 Like

we should probably stay on topic, but:
its not the size that counts, its how you use it!

1 Like

I use what the script returns to do a DBget on an asteriskdb family relating that data to endpoint, sometimes the city is useful, sometimes just the state. You can adjust the script to just extract any two digit state from a land line

Just saw somebody did something simiar to this before :slight_smile:

I believe this has been on a few wish list and is even in my “things to do eventually” pile.

It is probably a day or two work to write but finding a day or two can be challenging.

Basically using libphonenumber convert the number to the state, then you can choose destination by state. Not as fine-grained as per area code but that could get obnoxous

Python version using libphonenumber

#!/usr/bin/env python3
import sys
import phonenumbers
from phonenumbers import geocoder
PN = geocoder.description_for_number(phonenumbers.parse(sys.argv[1], "US"), "US")
DESC = PN.split(",")
try:
    print("database get STATE2ENDPOINT",DESC[1].strip(), end = '')
except:
    print("database get STATE2ENDPOINT",DESC[0].strip(), end = '')

You will get either CA or California depending (or Paris or London :slight_smile: )

Paris, TX or London, ON?

1 Like

That would depend on what argv[1] was :wink: +1NXXNXXXXXX or 1NXXNXXXXXX or NXXNXXXXXX would return the NANP ones, +33.X or 01133.* the French and +44.* or 01144.* the UK ones, , the number must however match what is ‘possible’ and ‘valid’ in that locale, so 011441207778888 would return a null as would 13231501244

The library can do a lot more than this snippet uses, like TimeZone

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.