How to route inbound calls based on the calling number's state code

This should route Texas inbound calls to the number 800555212?

What is the other number? Is it for anonymous calls?
Forgive my ignorance

yes
yes
and
Sure

I got one last question, Sorry for asking much but where should the main toll free number go in this script. because the call flow should be as in the following…

All states inbound calls will come to the Company’s main Toll free number (888-xxx-xxx) then based on the state caller is coming from it’ll get routed to the office where the caller’s state is (877-xxx-xxx). Catchall number can also be the same as the main toll free number (888-xxx-xxx)

In order for all calls to come to the main toll free number then get routed according to this criteria should I do this?
1- Replace ${EXTEN} with the main toll free number
2- rasterisk -x ‘database put STATE TX STATE-OFFICE-NUMBER’

?

Thank you so much

Yes , replace

\\${EXTEN} in the script with 888NXXXXXX

Then overwrite for states with particularoffice numbers

Hi Dicko, the comment [trythis-inbound-context]
I placed the inbound text in extensions_custom.conf file and tried to call after I changed the script’s #{EXTEN} with the number I wanted to test with. here is how it looks like (Just to make sure)

sed -i ‘s/ //g’ area_codes_by_state.csv;sed -n -e ‘2,$p’ area_codes_by_state.csv|awk ‘{print "rasterisk -x "database put NPA “$1” “$3""\nrasterisk -x "database put STATE “$3” 1XXXX1620"”}’ |tee bashstuff

I tried calling but it didn’t work, I deleted all inbound routes that I had previously it didn’t go anywhere as well. Created an empty inbound route and pointed it to Skype for Business. didn’t work again.

What am I doing wrong?

Thank you :slight_smile:

As ever you should post a log of a failed call

Hi Dicko,

If I don’t assign the number any inbound route, when I call it would say the number you have dialed is not in service . here is the logs

If I assigned a skype for business user a DID, that user will get the call but it wont be routed based on the caller ID’s state code.

for the main toll free number, do I have to create any inbound route or assign any destination from GUI?

Thank you

But your trunk context is from-trunk not trythis…

I have added the text as you have mentioned to the file extensions_custom.conf and made the call.
the number 1xxxx1620 is not in any inbound route which I have left (2 only there)

How to force FreePBX to use this trythis inbound route?

What context does InboundClientTrunk send it’s calls to?

Nothing I guess at the moment these are the settings for the inbound
Calls come from Telnyx (Sip trunk provider) . I tried adding context=trythis-inbound-context

After I tried to make a call, It says “All circuits are busy now” after removing the context the calls to other assigned numbers to extensions work fine but the 1620 main number says “The number is not in service”

disallow=all
type=friend
insecure=port,invite
host=192.76.120.10
dtmfmode=rfc2833
allow=ulaw

Put the context back, paste a failed call

I just did, Made a call and it failed …

The rest of the call attempt log

I can see now something in the logs, it says “chan_sip.c: Section ‘trythis-inbound-context’ lacks type
The DID number 248-653-1630 is already assigned and used to work prior to adding the context .

The other toll free number is not written anywhere except in the script that you gave me where numbers are written.

seems a strange number to call :wink:

Now after I stripped the state from 1, and calls are getting directed to this number however, when I call the number which is assigned to an extension the calls fails and says all circuits are busy now. I checked if there’s any weird number but didn’t find anything. it could be destination issue but I am not certain.

The number 1630 is assigned on Exchange’s Auto Attendant, The number 1680 is assigned to extension 7001.

Toll free in this case is 1XXXX1620
1XXXX1630 is Auto Attendant
2XXXX1680 is extension 7001 on PBX

Attaching a call example> >

Respectfully I will leave that to you to figure out, ( I have spent quite too much time on this) but you have a very special situation and not enough experience. Maybe hire a consultant?

I believe all your answers in already in the FM’s :wink:

No problem, thanks a lot you helped me pretty much with everything on this one.

1 Like

Bon Voyage, and let us all know how it works out please.