prepend area code digits per-extension?
I've looked all over, and I can't seem to find any HOWTO's that cover this:
How can I configure a unique dialplan addition at the extension level? I have a shared Trixbox that I have several different business customers using out of different area codes. To date, I have edited the dialplan of the local ATA or equipment to prepend the area code, but I want to do this centrally, and eliminate the step with the equipment!
How can I prepend area code per extension? I guessed that somehow I could do it by creating a custom context, so maybe I'm part of the way there...
I have created a context in extensions_custom.conf called "from-areacode" that doesn't do anything at the moment:
[from-areacode]
**insert cool "add area code to string" line here**
include => from-internal
I then changed the context of the extension from "from-internal" to "from-areacode".
Am I on the right track? And what exten => ... etc. line would I use to add an area code? I'm not too experienced in the dialplan side of things. Any help would be appreciated.
Thanks in advance!!
This is a little crazy. It seems that ${exten} and ${EXTEN} are different variables, even though all of the manuals say they are the same. Here is my code.
[from-areacode]
exten => _x.,1,noop(${EXTEN})
exten => _x.,n,set(EXTEN="77"${EXTEN})
exten => _X.,n,goto(from-internal,${exten},1)
What is crazy here is that I set the ${EXTEN} variable, it also sets ${exten} variable, but when I used ${EXTEN} in the go to statement, it fails. Since I could not make the ${EXTEN} variable change, I had to use a goto instead of an include.
Anyway, replace the "77" with your area code to insert, like "301". The quotes are important.
err, that reads like it is arbitrarily adding the extra digits to every string dialed. In my case, I'm only wanting to match 7 digits dialed. I presume I would replace the _x. with, maybe _xxxxxxx (omitting the ".") to run this rule against only 7 digit extension strings?
Just a guess, would I modify this code thusly:
[from-areacode]
exten => _xxxxxxx,1,noop(${EXTEN})
exten => _xxxxxxx.,n,set(EXTEN="77"${EXTEN})
exten => _X.,n,goto(from-internal,${exten},1)
?? obviously I want the last rule to run against all dialed. I dunno - I'll play with this and we'll see. Going the right direction - thanks so much for your input.
just tried it, and the "" are hurting us on line 2 of the context
[from-areacode]
exten => _x.,1,noop(${EXTEN})
exten => _x.,n,set(EXTEN=77${EXTEN})
exten => _X.,n,goto(from-internal,${exten},1)
removing the quotes as above made it work, at least for the arbitrary prepend context above - now I just need to tweak it to conditionally prepend the digits only if xxxxxxx is matched... stay tuned...
OK, seems to work as I needed it to rewritten as such:
[from-555]
exten => _XXXXXXX,1,noop(${EXTEN})
exten => _XXXXXXX,n,set(EXTEN=555${EXTEN})
exten => _XXXXXXX,n,goto(from-internal,${exten},1)
include => from-internal
If the extension is a 7 digit dial, it runs the scripts to prepend the 555, otherwise it drops to the from-internal context, and normal routing ensues.
This also solved a secondary need of mine, and maybe it'll help someone else. I'll do the same to enable a denser capacity of a shared "Hosted PBX" box that multiple customers share. To date, I have been assigning 5 digit extensions so as not to step on each other's toes extension-wise. However, many of my smaller customers don't like the 5 digit extensions, and would prefer 2 or 3 only. Clearly I can't do this, but I can use this trick to prepend the first 2 or 3 digits into their dial patterns, and allow them to ostensibly use a abbreviated dialing for their back-end extension calling. Cool stuff.
Thanks so so much for this set(nugget=gold) tidbit... thats exactly the tip I needed.
I have a couple of extensions that are in the houses of friends of mine. I use this code to prevent them from calling 911 through my house. You can modify this code to prevent long distance calls.
[from-wan]
exten => 911,1,Noop(Remote extension cannot dial 911)
exten => 911,n,system(echo You may not dial 9 1 1 from this extension. > /tmp/out.txt)
exten => 911,n,system(echo Please use a land based phone >> /tmp/out.txt)
exten => 911,n,system(cat /tmp/out.txt | text2wave -o /tmp/my_new_sound.ulaw -otype ulaw)
exten => 911,n,Playback(/tmp/my_new_sound)
exten => 911,n,zapateller()
exten => 911,n,hangup()
include => from-internal
You might be able to do it this way:
[from-block-ld]
exten => _1XXXXXXXXXX,1,hangup()
exten => _011x.,1,hangup()
include => from-internal
You may want to make this code a little more polite, but that will get you started.
hi .. can anyone please help.. when i click on the packages i got this error
Warning: fread(): Length parameter must be greater than 0. in /var/www/html/maint/includes/functions/genYumArray.php on line 17
Warning: fread(): Length parameter must be greater than 0. in /var/www/html/maint/includes/functions/genYumArray.php on line 21
Warning: fread(): Length parameter must be greater than 0. in /var/www/html/maint/includes/functions/genYumArray.php on line 196

Member Since:
2007-12-05