[asterisk-users] Simplifying dial-plan

Stephen Reese rsreese at gmail.com
Thu Dec 23 04:12:45 UTC 2010


On Wed, Dec 22, 2010 at 12:59 PM, Warren Selby <wcselby at selbytech.com> wrote:
> On Tue, Dec 21, 2010 at 6:59 PM, Stephen Reese <rsreese at gmail.com> wrote:
>>
>> On Tue, Dec 21, 2010 at 7:58 PM, Stephen Reese <rsreese at gmail.com> wrote:
>> > Is there a way to include:
>> >
>> > _NXXNXXXXXX
>> > _NXXXXXX
>> > _011.
>> > _911
>> >
>> > into my current plan:
>> >
>>
>> Sorry, here's the rest.
>>
>> exten => _1NXXNXXXXXX,1,Set(Outgoing=${CUT(CHANNEL,/,2)})
>> exten => _1NXXNXXXXXX,n,Set(Outgoing=${CUT(Outgoing,-,1)})
>> exten => _1NXXNXXXXXX,n,GotoIf($["${Outgoing}" = "201"]?20:10)
>> exten => _1NXXNXXXXXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
>> exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN}@vitel-outbound)
>> exten => _1NXXNXXXXXX,n,Goto(h,1)
>> exten => _1NXXNXXXXXX,20,Set(CALLERID(all)=${EXTERNAL_CALLERID})
>> exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN}@vitel-outbound2)
>> exten => _1NXXNXXXXXX,n,Goto(h,1)
>>
>
> Why not make a Macro (or GoSub) to handle this block of code, and then your
> outbound dial lines are just one line calling the Macro?  Saves a lot of
> repeating blocks of code. Something like this (not tested):
>
> [macro-OutboundDial]
> ; ${ARG1} = CHANNEL
> ; ${ARG2} = EXTERNAL_CALLERID
> exten => s,1,Set(Outgoing=${CUT(${ARG1},/,2)})
> exten => s,n,Set(Outgoing=${CUT(Outgoing,-,1)})
> exten => s,n,GotoIf($["${Outgoing}" = "201"]?outbound2:outbound1)
> exten => s,n(outbound1),Set(CALLERID(all)=${ARG2})
> exten => s,n,Dial(SIP/${MACRO_EXTEN}@vitel-outbound)
> exten => s,n,Goto(h,1)
> exten => s,n(outbound2),Set(CALLERID(all)=${ARG2})
> exten => s,n,Dial(SIP/${MACRO_EXTEN}@vitel-outbound2)
> exten => s,n,Goto(h,1)
>
> [outbound-context]
>
> exten => _NXXNXXXXXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _NXXXXXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _011.,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _911,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
>
>
> --
> Thanks,
> --Warren Selby, dCAP
> http://www.selbytech.com

Thanks Warren, that's what I'm looking to do.

First question is where did ${MACRO_EXTEN} come from, I assumed
${EXTEN} is a built in variable?

Secondly, where would the 1 and/or area-code need to be placed? Could
an additional argument be used to specify the prefix, i.e. a third
variable be specified in the outbond-context to implement the
OutboundDial macro, or is the MACRO_EXTEN suppose to be an
implementation of this?

exten => s,n,Dial(SIP/{$ARG3}${MACRO_EXTEN}@vitel-outbound2)

As Jeroen mentioned previously a goto may be used, would this help,
seems similar to what I am trying to accomplish.

exten => _NXXNXXXXXX,1,Goto(1${EXTEN},1)
exten => _NXXXXXX,1,Goto(1555${EXTEN},1)

Thanks,
Stephen



More information about the asterisk-users mailing list