[asterisk-users] Re: Match a Numer - then continue with, dialplan
David Gomillion
dgomillion at eyecarenow.com
Wed Dec 20 10:26:52 MST 2006
I think you're making it far too difficult.
What I do is something like this:
[outgoing]
include => internal
include => longdistance
;Always include internal first, as matches from the first include
;will be used first. This allows you to make sure your internal
;extensions don't go out your trunks.
[longdistance]
ignorepat => 9;
include => default; already included from local, but putting here for
clarity
include => local;
exten => _91XXXXXXX,1,Macro(trunkout,${EXTEN}) ;Medium Distance
exten => _91XXXXXXXXXX,1,Macro(trunkout,${EXTEN}) ;Long Distance
Then, I have:
[macro-trunkout]
exten => s,1,Set(cname=${DB(showname/${CALLERIDNUM})});
exten => s,n,Set(cnum=${DB(shownum/${CALLERIDNUM})});
exten => s,n,GotoIf($["foo${cnum}" = "foo"]?6); //if calling from ZAP
channel that set caller ID already
exten => s,n,Set(CALLERID(name)=${cname}|a);
exten => s,n,Set(CALLERID(number)=${cnum}|a);
exten => s,n,Dial(${TRUNK}/${ARG1:${TRUNKMSD}});
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-ANSWER,1,Hangup
exten => s-CONGESTION,1,Congestion(30)
exten => s-CONGESTION,2,Hangup
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-BUSY,2,Hangup
Why is this important? It's not. But it is fundamentally different from
what you're asking. You want to match a partial extension dialed and
then continue appending digits. What you really need to do is wait for
the whole number, then decide what kind of number it is, do the
processing, and send it on its way. It's just a slight change in the way
you're thinking, because you understand that there's a class of numbers
to treat differently. And that's OK. Just don't do anything with it
until the whole extension has been entered!
You'll notice that, anything not going through the trunkout macro
doesn't get tweaked, and anything that goes through there will read from
the database. I could just as easily set a single value, but I have some
users that I want to go out as themselves, and different departments
that have a general number, etc. I found the Asterisk Database to be the
easiest to tweak, as I have some scripts to allow admins to change the
effective CallerID on the fly.
I hope this helps! Asterisk can do what you're asking, and it does every
day.
More information about the asterisk-users
mailing list