8 digit dialing -> 10 digit dialing in bridge with variability for area code

Status
Not open for further replies.

simcard

Member
Jan 22, 2017
49
4
8
The title might seem somewhat confusing, but it was the only way I could describe it.

Trying to do something here that I haven't seen done before. I've seen similar examples (see '7 digit dialing' at https://wiki.freeswitch.org/wiki/Home_PBX_Example), but nothing that takes into account area code variability. Looking for opinions/comments if anyone else has had a crack at this.

Scenario is as follows;

Like most countries, we have area codes for regions. If you dial a number in the same area code, you don't need to add the area code. We'd like to allow customers who are calling numbers in their same area code to either dial with or without, but always send these to our upstream carriers as a full number with area code.

e.g.
numbers with area codes are 10 digits (2 digit area code), while numbers without area codes are 8 digits; with area code: 02 8000 9000, or without area code 8000 9000.If the customer is also located in the '02' area code, they could reach the same number using either dialing method.

The variability I mentioned above comes from the different area codes that might be used (02, 03, 07 and 08 in this case). The issues with the example in the link above assumes one area code.

In our situation, each extension is allocated a phone number, so one of the ideas we thought about was implementing a step into the dialplan to break out the extension's area code from the outgoing caller id and then pre-pend this to the number when bridging.

This option means no custom development and no need to maintain an additional setting. Seems relatively straight forward, but before we start hacking a dialplan together, it would be good to see what, if anyone else is doing.

Anyone come across this scenario or have any gotcha's to keep in mind?
 

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
e.g.
numbers with area codes are 10 digits (2 digit area code), while numbers without area codes are 8 digits; with area code: 02 8000 9000, or without area code 8000 9000.If the customer is also located in the '02' area code, they could reach the same number using either dialing method.

This is a standard feature of Outbound dialplan. You can chain dialplan blocks in order with each block handles a specific destination pattern.

From your question it looks like you are in Australia NSW?
 

simcard

Member
Jan 22, 2017
49
4
8
Our outbound route list looks very similar to yours :)

I understand what you mean, the difficulty we were facing was how to cater for different customers across area codes e.g. it's not always 02 or 03. It's multi-tenant and I'd rather not need to create a new dialplan entry for each customer we setup to specify one of the four area codes.

Depending on the who we're terminating the call with, we'll either need to send the call as a full national number (acxxxxyyyy) or with the country code + area code (612xxxxyyyy); while it's simple to get the call in the right format for the different upstreams. The struggle was how we could work out what the appropriate area code should be for any particular customer through a new o/b dialplan block.

I think we might have it though using an o/b dialplan. Our concept is that we'd run the caller_id_number through a condition after we detect 8 digits being dialed. This condition captures the area code (or at least the '2' from the 02) and we can prepend to the number when bridging, which gives us the flexibility we need with the way we need to send calls..

Still need to mock-up a dial plan and test; that's for tomorrow.


From your question it looks like you are in Australia NSW?

South of the border; Melbourne. I used 02 as an example area code as I'd just got off the phone to a customer in Sydney so it was top of mind. Looking at your dialplans, you're in Vic too?
 

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
Looking at your dialplans, you're in Vic too?
Yup.

Our concept is that we'd run the caller_id_number through a condition after we detect 8 digits being dialed.

This won't work if the customer is in one state but doing business in another state or states showing caller id for that state.

If I were you, I would enter the area code in Advanced->Variables->Default->default_areacode (eg. 2, 3 etc) and add the ${default_areacode} variable in the bridge line.
 

simcard

Member
Jan 22, 2017
49
4
8
Thanks for your help EasyBB - managed to get it working. We didn't go with the ${default_areacode} in the end as we couldn't see anywhere to specify this variable per customer. If we set it as a global variable as '03', then customers from sydney and brisbane will end up dialing melbourne numbers when dialing with 8 digits.

We instead went with our concept of lifting the area code from the outgoing caller id number and prepending that to the 8 digit number. The assumption we're using is that customers are already primed to dial the area code when calling interstate, while they expect to be able to use 8 digits in their home state (a legacy of the pstn/isdn networks), so we need the home state area code (and assuming we follow the telephone numbering plan rules, this should give us what we need).


Our final test dialplan that appears to be working with the testing we've done is:

fusionpbx.png

It's currently missing the fall back to our other gateways and subsequent number manipulation like the one in EasyBB's.

We don't currently have any customers presenting 'out of state' caller id's (e.g. a melbourne office displaying the sydney head office number on outbound calls), however one option is to switch to capturing the areacode from the effective caller id and set this to the extensions phone number, leaving outbound caller id to be set to which ever number the customer wants and change the dialplan accordingly.
 
Dec 1, 2016
92
8
8
45
inside-out.xyz
I did this for an Australian customer last month. If you dial with 7 digits it uses local area code. You need to play with heavy dial planning and with caller_id_* variables.

Contacte privately if you need dedicated support
 

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
We didn't go with the ${default_areacode} in the end as we couldn't see anywhere to specify this variable per customer.
Sorry, I didn't realise you were talking about a multi-tenant system. I think you can have a variable defined in dial plan manager that differs in value depending on the domain.

Your solution looks good. Just wondering what happens to those customers that don't have a DID or don't want to show a caller id?

Also the regex on your group 1 can be cleaner:
Code:
^(0[2378])(\d{8})$

and group 2 regex can be:
Code:
^([2-9]\d{7})$
 

simcard

Member
Jan 22, 2017
49
4
8
Sorry, I didn't realise you were talking about a multi-tenant system. I think you can have a variable defined in dial plan manager that differs in value depending on the domain.

All good - I noticed I wasn't clear in my original post about multi-tenant.

According to the FreeSwitch wiki, area_code should be able to be set per domain or per user, with the latter being the better option for this use case.

Your solution looks good. Just wondering what happens to those customers that don't have a DID or don't want to show a caller id?

Yep - I knew I posted up here for a reason - didn't think about those scenarios. I'll continue to investigate further how to set the area_code per extension and see where I get to.

Also the regex on your group 1 can be cleaner:
Code:
^(0[2378])(\d{8})$

and group 2 regex can be:
Code:
^([2-9]\d{7})$

Much appreciated - still getting my regex in shape after years of not using it a whole lot.
 

TheOperator

Member
Nov 30, 2016
39
13
8
Bavaria, Germany
Another way to manipulate outbound numbers is mod_translate and regex tables . I am using it to adjust my outbound numbers so that they are accepted by my providers.
This is a section taken from my "translate.conf.xml":

upload_2017-3-31_19-5-15.png

The actual translation is the done in the outbound dialplan by calling mod_translate via "${translate ...}" as shown below:

upload_2017-3-31_19-11-54.png

This simplified my outbound dialplans a lot.
 

simcard

Member
Jan 22, 2017
49
4
8
The actual translation is the done in the outbound dialplan by calling mod_translate via "${translate ...}" as shown below:

TheOperator,

What is the result of the translation in the CDRs? Do you see the translated number in the CDRs or the original number (pre-translated)?
 

TheOperator

Member
Nov 30, 2016
39
13
8
Bavaria, Germany
Simcard,

According to my old logs, you should see the translated number in the CDR.
If you want to do global translations before the number hits the dialplan, you can use mod translate in the SIP profile. This approach has one drawback - you can't select the translation table to use dynamically. It will always use the translation table for the country code configured in the domain settings of Freeswitch / FusionPBX.
Currently I am using both methods, as this enables me to clean inbound numbers as well, which is usefull for call-blocking, cid-lookup, a tidy CDR and other things.

My global settings look like this (Country code is DE here):

upload_2017-5-2_10-8-20.png

and is called in the SIP profile using:

upload_2017-5-2_10-10-39.png

Using mod translate on inbound calls modifies destination_number and caller_id_number, so you might have to reconfigure your desitination & inbound routes.
 
Status
Not open for further replies.