Kevin P. Fleming
2004-Sep-02 19:42 UTC
[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?
I've got a need to do something like the following: [foo-context] exten => _.,1,SetCIDNum(123) exten => _.,2,SetCIDName(XYZ) include => local include => tollfree But of course, this example won't work. The goal here is this: if a call ends up being handled by the "local" or "tollfree" contexts, I want those SetCID*** commands executed. Otherwise, I don't want them executed. I don't want to embed them into the local/tollfree contexts themselves, because then I'd have to figure out some way to store the "123" and "XYZ" values so that they could be used by commands in those contexts. Essentially, what I want to do is override the CALLERIDNUM/CALLERIDNAME data for calls that are directed outside the PBX, and leave it alone for calls inside the PBX. That way internal users can see "John Q. Smith <322>" (different for each extension), but outside callees see "Smithco Widgets <602-555-1212>" (which would be identical for all of the extensions that can make outside calls).
Rob Fugina
2004-Sep-03 07:22 UTC
[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?
Use the 's' extension... On Thu, 02 Sep 2004 19:42:13 -0700, Kevin P. Fleming <kpfleming@backtobasicsmgmt.com> wrote:> I've got a need to do something like the following: > > [foo-context] > exten => _.,1,SetCIDNum(123) > exten => _.,2,SetCIDName(XYZ) > include => local > include => tollfree > > But of course, this example won't work. The goal here is this: if a call > ends up being handled by the "local" or "tollfree" contexts, I want > those SetCID*** commands executed. Otherwise, I don't want them > executed. I don't want to embed them into the local/tollfree contexts > themselves, because then I'd have to figure out some way to store the > "123" and "XYZ" values so that they could be used by commands in those > contexts. > > Essentially, what I want to do is override the CALLERIDNUM/CALLERIDNAME > data for calls that are directed outside the PBX, and leave it alone for > calls inside the PBX. That way internal users can see "John Q. Smith > <322>" (different for each extension), but outside callees see "Smithco > Widgets <602-555-1212>" (which would be identical for all of the > extensions that can make outside calls). > _______________________________________________ > Asterisk-Users mailing list > Asterisk-Users@lists.digium.com > http://lists.digium.com/mailman/listinfo/asterisk-users > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >
Kris Boutilier
2004-Sep-03 08:26 UTC
[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?
You need to a method other than 'include =>', which effectively concatenates the target of the include with the current context. Consider this approach instead: [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 needs to match the criteria for local, say a 9 prefix exten => _9.,1,SetCIDNum(123) exten => _9.,2,SetCIDName(XYZ) exten => _9.,3,Goto(local,${EXTEN},1) 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) ; This needs to match the criteria for local, say a 9 prefix exten => _9.,1,Macro(setOutgoingCLID) exten => _9.,2,Goto(local,${EXTEN},1) [macro-setOutgoingCLID] exten => s,1,SetCIDNum(123) exten => s,2,SetCIDName(XYZ) You'll need to implement 't' and 'i' handlers in [foo-context] and, possibly, seperate 'h' handlers in [local] and [tollfree]. Hope that helps. Kris Boutilier Information Systems Coordinator Sunshine Coast Regional District -----Original Message----- From: Kevin P. Fleming [mailto:kpfleming@backtobasicsmgmt.com] Sent: September 2, 2004 7:42 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context? I've got a need to do something like the following: [foo-context] exten => _.,1,SetCIDNum(123) exten => _.,2,SetCIDName(XYZ) include => local include => tollfree But of course, this example won't work. The goal here is this: if a call ends up being handled by the "local" or "tollfree" contexts, I want those SetCID*** commands executed. Otherwise, I don't want them executed. I don't want to embed them into the local/tollfree contexts themselves, because then I'd have to figure out some way to store the "123" and "XYZ" values so that they could be used by commands in those contexts. Essentially, what I want to do is override the CALLERIDNUM/CALLERIDNAME data for calls that are directed outside the PBX, and leave it alone for calls inside the PBX. That way internal users can see "John Q. Smith <322>" (different for each extension), but outside callees see "Smithco Widgets <602-555-1212>" (which would be identical for all of the extensions that can make outside calls). {clip}
Kris Boutilier
2004-Sep-03 08:29 UTC
[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?
If 'immediate=yes' then the target exten in the context for the zap line will always be 's', where you would implement digit collection or whatever. If 'immediate=no' then the simple switch code will collect the digits and dive in to the context with something to match against, thereby ignoring 's'. -----Original Message----- From: Rob Fugina [mailto:rob.fugina@gmail.com] Sent: September 3, 2004 8:19 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context? Ah, well... Never tried it with SIP phones. I thought I had used that before for inbound calls on a Zap channel, and with local Zap extensions, too... On Fri, 03 Sep 2004 08:11:09 -0700, Kevin P. Fleming <kpfleming@backtobasicsmgmt.com> wrote:> Rob Fugina wrote: > > Use the 's' extension... > > > > Uhh, no. That doesn't work at all. >{clip}
Kris Boutilier
2004-Sep-03 19:45 UTC
[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?
Hmmm... try this then: [foo-context-companya] exten => _.,1,DigitTimeout(2) ;2 second pause signifies end of dialing exten => _.,2,SetVar(target=${EXTEN}) exten => _.,3,SetVar(companyCIDNum=18005551212) exten => _.,4,SetVar(companyCIDName=companya) exten => _.,5,Goto(step2${dialed},1} include => tollfree include => local [foo-context-companyb] exten => _.,1,DigitTimeout(2) ;2 second pause after dialing exten => _.,2,SetVar(target=${EXTEN}) exten => _.,3,SetVar(companyCIDNum=18775551212) exten => _.,4,SetVar(companyCIDName=companyb) exten => _.,5,Goto(step2${exten},1} include => tollfree include => local ; Generic includes (could be in seperate file) [tollfree] exten => _step291800.,1,SetCIDNum(companyCIDNum) exten => _step291800.,2,SetCIDName(companyCIDName) exten => _step291800.,3,Dial(resource/${target}) [local] exten => _step29.,1,SetCIDNum(companyCIDNum) exten => _step29.,2,SetCIDName(companyCIDName) exten => _step29.,3,Dial(resource/${target}) However this means an enblock/predialing environment rather than the conventional free running pattern matcher - fine if the outbound resource has really fast call setup (such as PRI) but not so good if you're doing inband DTMF a 2 digits per second, such as normal analog lines. In that case you'd need lots of nasty audio-handholding so people don't get too confused with the silence on the line during the call setup... which is where I'm at. :-) -----Original Message----- From: Kevin P. Fleming [mailto:kpfleming@backtobasicsmgmt.com] Sent: September 3, 2004 10:46 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context? 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. {clip}
Kris Boutilier
2004-Sep-03 20:18 UTC
[Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context?
Grrr.... Both occurances of: exten => _.,5,Goto(step2${dialed},1} should have read: exten => _.,5,Goto(step2${target},1} -----Original Message----- From: Kris Boutilier [mailto:Kris.Boutilier@scrd.bc.ca] Sent: September 3, 2004 7:46 PM To: 'Asterisk Users Mailing List - Non-Commercial Discussion' Subject: RE: [Asterisk-Users] Any way to _always_ execute certain commands in a dialplan context? Hmmm... try this then: [foo-context-companya] exten => _.,1,DigitTimeout(2) ;2 second pause signifies end of dialing exten => _.,2,SetVar(target=${EXTEN}) {clip}