[asterisk-users] Simplifying dial-plan

Warren Selby wcselby at selbytech.com
Wed Dec 22 17:59:56 UTC 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20101222/c8deb999/attachment.htm>


More information about the asterisk-users mailing list