Inbound route based on country


Can someone help us changing inbound route based on country.
We have all routes setup with speaks in local langauge. But we want to change to English audio for all non national calls.

Is there a way in freepbx to detect if call is not national and the route to different announcement?



Make an inbound route and use a cid patern to match all national calls, inside this rule set the language you want.
Now make a any did/any cid rule and set there the language to English.

Another idea would be to set up a programmable context that would look up the country code in the CID and set the language based on that.

IIRC, once the language code is set, the system will automatically use the Internationalized Greeting (assuming you have one) for that country.

Note, this is outside my experience area, so it might be a little tougher than that, but I know that there is language specific lang-packs associated with the system that you can turn up. Putting the IVRs for your countries’ greetings into the language specific IVR might be simple enough to make work.

You only need one IVR, you need to have appropriate language specific recordings in a all the /var/lib/asterisk/sounds/(language)/* directories , en,fr,in, whatever.

The one that will be played is the one that matches the channel variable ${LANGUAGE()} you can set that previously on the channel with:-


The trick is to set the language on an inbound call by checking the ${CALLERID(num)} bit that aligns with what you get, for example

if ${CALLERID(num}} = 011493445667879 then the call is from Germany but it might also present as

+493445667879 or 493445667879 or 001493445667879.

same goes for Italy where 49 would be 39 the rest can be found at

So send the calls to a custom context that splits off the coutrycode appropriately and sets the LANGUAGE appropriately, a good template is the [from-pstn-e164-us] context in /etc/asterisk/extensions.conf.

seems like something you might be able to do with superfecta and a little effort…

         "Federal Republic of Germany",
         "Bundesrepublik Deutschland"
      "subregion":"Western Europe",

Hi Dicko,

Thanks for your description.

It sounds like a correct approach :slight_smile:
But can you help me a bit more what exactly to do with:
[from-pstn-e164-us] context in /etc/asterisk/extensions.conf.

I suggest you carefully look at [from-pstn-e164-us] then copy it into /etc/asterisk/extensions_custom.conf as [custom_from_pstn_mine]

NANP numbers are “closed” every one is 10 digits long, you can often add the “country code” (1) , so for example

exten => s/_011NX.,n,Goto(from-pstn,${EXTEN},1)

might be replaced with

exten => s/_011NX.,n,Set(LANGUAGE()=xx)
exten => s/_011NX.,n,Goto(from-pstn,${EXTEN},1)

and add specifically

exten => s/_01149X.,n,Set(LANGUAGE()=de)
exten => s/_01149X.,n,Goto(from-pstn,${EXTEN},1)

where you have defined your own language xx in /var/lib/asterisk/sounds/xx/* and added appropriate files.

you can of course use anything there, it is basically freeform but also there are many conventially predefined ones like en-GB, fr and de ( ). The somewhat anomalous hardcoded default is “en”, ( it should surely properly be en-US :wink: ) which if you have /var/lib/asterisk/sounds/en/ (which is likely)

send you inbound calls to that context.

It all depends on how the CALLERID(num) is presented and by what means you can define your “national calls” perhaps by length , perhaps by MostSignificantDigits.