Posts Tagged ‘dialplan expressions’

How To compose a Transparent Dialplan

Tuesday, May 13th, 2008

A simple dialpan rule may look like this:

exten => _X.,1,Switch(VOIPBUSTER)

or:

exten => _X.,1,Switch(${EXTEN}@VOIPBUSTER)

(to set other $ and {EXTEN} values)

(at the bottom of this blog, you’ll find a Ruby translation)

This will dial all you dial (exactly) with provider VOIPBUSTER or any other, which you gave that name, When you registered that provider, with that particular “Provider Name”

But this would mean, you only can make a phonecall, when you dialed the complete International dialing sequence, also for someone that lives in your own city, that’s a bit clumbsy,

and you have to “instruct” the other people using your phone system, So, you want to overcome this, and it can !

Here comes the “transparent” part !

Say, you always have to dial: (i’m living in the Netherlands) 0031 for the Netherlands, and 020 for Amsterdam, and 1234567 for the subscriber, what should be dialed is: 0031201234567 (notice the first 0 of the city dial code should not be dialed, when dialing internationaly) Your dialplan rule could look like this:

exten => _ZX.,1,Switch(003120${EXTEN}@VOIPBUSTER)

The first part in the dialplan detects you are not dialing a zero, (expression letter is used, for a value in the 1 - 9 range) see the dialplan expressions list below.

Now, this will be dialed by MySIPSwitch: 003120 + what you have dialed in the first place.. For dialing nationaly/internationaly, you can figure out in the same way a “plan” detecting te amount of zero’s depending how “far” the call will go, nationaly:

exten => _0ZX.,1,Switch(0031${EXTEN:1}@VOIPBUSTER)

or internationaly:

exten => _0032X.,1,Switch(${EXTEN}@VOIPCHOICE)

and according to the country code, which provider you want to use for that destination, that is the cheapest way to do so…. you use one of the Provider (Name)’s, you have registered.

btw. keep in mind you ‘re using your dialplan at MySIPSwitch, so you do not do this in your ATA or SIP phone, these settings should be completely transparent, and accept all combinations, and do nothing with it, just pass it through, otherwise your dialplan at MySIPSwitch will not respond like here is mentioned.

A Ruby translation for outgoing only:

when /^06/ then sys.Dial(”00316${dst:2}@INTERVOIP”)

in the above sample, you see 06 is detected, 00316 plus what’s keyed in, minus the first two digits that where keyed in.  >  dst:2 with the INTERVOIP provider,  06 are the first digits dialed in the Netherlands, to dial a mobile phone, nationally, 0031 is the international code needed for VoIP, and the first zero shouldn’t be dialed, just like with the city dial code. you can edit this rule to your likings, edit the “06″ edit or remove the “00316″ or edit or remove the “:2″

TheFug.

btw: some dialplan expressions:

X - any digit from 0-9

Z - any digit from 1-9

N - any digit from 2-9

[1235-9] any digit in the brackets

. wildcard, matches anything remaining