Inbound route based on country

Hi,

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?

Thanks

Dave

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:-

Set(LANGUAGE()=language)

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 https://countrycode.org/

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…

https://restcountries.eu/rest/v1/callingcode/49

[
   {
      "name":"Germany",
      "capital":"Berlin",
      "altSpellings":[
         "DE",
         "Federal Republic of Germany",
         "Bundesrepublik Deutschland"
      ],
      "relevance":"3",
      "region":"Europe",
      "subregion":"Western Europe",
      "translations":{
         "de":"Deutschland",
         "es":"Alemania",
         "fr":"Allemagne",
         "ja":"ドイツ",
         "it":"Germania"
      },
      "population":81083600,
      "latlng":[
         51.0,
         9.0
      ],
      "demonym":"German",
      "area":357114.0,
      "gini":28.3,
      "timezones":[
         "UTC+01:00"
      ],
      "borders":[
         "AUT",
         "BEL",
         "CZE",
         "DNK",
         "FRA",
         "LUX",
         "NLD",
         "POL",
         "CHE"
      ],
      "nativeName":"Deutschland",
      "callingCodes":[
         "49"
      ],
      "topLevelDomain":[
         ".de"
      ],
      "alpha2Code":"DE",
      "alpha3Code":"DEU",
      "currencies":[
         "EUR"
      ],
      "languages":[
         "de"
      ]
   }
]

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 ( https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx ). 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.