[Asterisk-Users] Interesting Dial-Plan Question

Roshan Sembacuttiaratchy rns.asterisklist.n.semba at xoxy.net
Thu Apr 27 05:55:40 MST 2006


On Thu, Apr 27, 2006 at 07:39:58AM -0500, Eric ManxPower Wieling scribbled:
> Matt wrote:
> >Hi,
> >When I setup a user, I give them an extension like 570xxxxxxx.   This
> >is fine and dandy while in one area code, but we've since gone to
> >other area codes.    I'd like the user's to retain the ability to dial
> >7 digits no matter what number they have.   Any thoughts on how to do
> >that?
> >
> >EXAMPLE:  User has number 7175551212.  I want that when they dial
> >3235555 it dials 717-323-5555.        User has number 5705551212.  I
> >want that when they dial 3235555 it dials 570-323-5555.
> >
> >I'm thinking I need to do some chopping, splitting, and variable
> >writing?    Am I correct in thinking that if I do all of this before
> >my current dialplan kicks in that I should be able to still use my
> >routing?
> >
> >IE: User dials 3235555 and is from 717 area code.   If I transform the
> >number to be 7173235555 the dial-plan will now read it as if the user
> >punched it in that way and process it?
> 
> exten => _NXXXXXX,1,Dial(Zap/g1/${CALLERIDNUM::0:3}${EXTEN})
> 
> This assumes that you set the user's Caller*ID number to be their 
> telephone number.  It takes the first 3 digits of their CALLERIDNUM and 
> prepends it to the number they dialed.

I've done something a bit different:

I use the Asterisk DB to store, for each extension, an associated 
country code and area code.  I then have a specific context, within 
which I handle the number procesing.  Thus, any number without a 0 in 
front, gets +(COUNTRYCODE)(AREACODE) prepended.  Any number with just a 
0 in front, gets the country code added (+(COUNTRYCODE)), and a number 
with the full 00 is considered a full number with country code and area 
code.  My code for this is as follows:

[processNumber]
exten => _ZX.,1,Set(COUNTRYCODE=${DB(extInfoCC/${CALLERID(NUM)})})
exten => _ZX.,n,Set(AREACODE=${DB(extInfoAC/${CALLERID(NUM)})})
exten => _ZX.,n,NoOp(Changing number from ${EXTEN} to 00${COUNTRYCODE}${AREACODE}${EXTEN})
exten => _ZX.,n,Goto(processNumber,00${COUNTRYCODE}${AREACODE}${EXTEN},1)

exten => _0ZX.,1,Set(COUNTRYCODE=${DB(extInfoCC/${CALLERID(NUM)})})
exten => _0ZX.,n,NoOp(Changing number from ${EXTEN} to 00${COUNTRYCODE}${EXTEN:1})
exten => _0ZX.,n,Goto(processNumber,00${COUNTRYCODE}${EXTEN:1},1)

exten => _00ZX.,1,NoOp(RepeatDial/${CALLERID(NUM)}=${EXTEN})
exten => _00ZX.,n,Set(DB(RepeatDial/${CALLERID(NUM)})=${EXTEN})
exten => _00ZX.,n,Set(NCDIAL=${EXTEN})
exten => _00ZX.,n,Goto(enumLookup,1)

exten => enumLookup,1,NoOp(Performing ENUM Lookup)
exten => enumLookup,n,Set(TRANSFER_CONTEXT=${SIPPEER(${CALLERID(NUM)}:context)})
exten => enumLookup,n,Set(TARGET=${ENUMLOOKUP(+${NCDIAL:2},sip,record=1,e164.org)})
exten => enumLookup,n,GotoIf($[${LEN(${TARGET})}=0]?noEnum)
exten => enumLookup,n,SetAccount(ENUM-Alt)
exten => enumLookup,n,Dial(SIP/${TARGET},20,T)
exten => enumLookup,n,Hangup
exten => enumLookup,n(noEnum),Goto(routeNumber,${NCDIAL},1)

[routeNumber]
...

You'll have to change this as appropriate to work with US number formats.

HTH,

Roshan

-- 
http://roshan.info

All true wisdom is found through yo-yos.



More information about the asterisk-users mailing list