[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?

Kevin P. Fleming kpfleming at backtobasicsmgmt.com
Fri Sep 3 10:45:52 MST 2004


Kris Boutilier wrote:

> [foo-context]
> ; This needs to match the criteria for tollfree, say a 91800 prefix
> exten => _91800.,1,SetCIDNum(123)
> exten => _91800.,2,SetCIDName(XYZ)
> exten => _91800.,3,Goto(tollfree,${EXTEN},1)

This is the direction I started going; however, I need to implement this 
for multiple clients, and I'm not keen on duplicating the pattern 
matching in separate contexts for each client. That's why I was trying 
to find a solution that would let me use an "included" context, but 
still provide commands to be executed if that included context found a 
match. I may work on coding this up, as I think it could be very useful.

> It could also be implemented as:
> 
> [foo-context]
> ; This needs to match the criteria for tollfree, say a 91800 prefix
> exten => _91800.,1,Macro(setOutgoingCLID)
> exten => _91800.,2,Goto(tollfree,${EXTEN},1)
> 
> [macro-setOutgoingCLID]
> exten => s,1,SetCIDNum(123)
> exten => s,2,SetCIDName(XYZ)

I also considered this, and if there was any way to have something like:

exten => _91800.,1,Macro(setCID#${ACCOUNTCODE})

then it would work well. I have not yet tried this, but based on the way 
the dialplan is imported into Asterisk (and displayed via "show 
dialplan"), I don't think it's possible for the decision of which macro 
to call to be made at run-time (as opposed to config file parsing time).

Another option would be to use Goto(Local/${ACCOUNTCODE}-CLID), to make 
the "subroutine" call at runtime, but I'm leery of doing that for a 
couple of reasons: it could seriously mess up my CDR, and I don't know 
(without testing) if SetCIDNum/SetCIDName changes made in the called 
context will propagate back (since going to "Local" sort-of creates a 
new channel).



More information about the asterisk-users mailing list