[asterisk-users] Selecting outbound trunk

Devraj Mukherjee devraj at gmail.com
Tue Aug 29 17:51:00 MST 2006


Hi Iain,

Thank you for that. That should work well for me.

On 8/29/06, Iain Young <iain at g7iii.net> wrote:
> On Tue, Aug 29, 2006 at 02:18:32PM +1000, Devraj Mukherjee wrote:
>
> > The simplest way I can think of solving this is using prefixes, so
> > someone appends a 0 or 1 and the dialplan puts the call through the
> > selected trunk, where 0 being voip and 1 being PSTN.
>
> Whats wrong with something like this :
>
> exten => _91X.,1,Dial(SIP/${EXTEN:2}@${OUTBOUND1})
> exten => _92X.,1,Dial(SIP/${EXTEN:2}@${OUTBOUND2})
> exten => _93X.,1,Dial(IAX2/iaxprov/${EXTEN:2})
>
> Users would dial 91 to dial outbound on SIP Provider 1, 92 for
> outbound on SIP Provider 2, and 93 for outbound on IAX. Personally
> I use 9X for automatic routing (along with some sane forced routing,
> ie local, emerg calls etc), and am planning on using 8X for manual
> forced routing.
>
> > I have figured out how to use a Substring like function to extract the
> > number out of the dialed extension. My question is how do I make a
> > decision in the dialplan to dynamically select a trunk for the call?
> > Is there a SetIf function or an If function by itself?
>
> Checkout the command GotoIf()
>
> Heres an example that I use to in my exten Macro, that does
> slightly different things depending on the number range the
> extension dialed is from:
>
> [macro-exten]
> exten => s,1,GotoIf($[${ARG1:0:1} = 1]?11:21)   ; Did we call a real ext ?
> exten => s,11,SetVar(TODIAL=${ARG2}/${ARG1})    ; Yes so we have the ext
> exten => s,12,Goto(91)                          ; Jump to Dial() routint
> exten => s,21,GotoIf($[${ARG1:0:2} = 20]?31:41) ; Did we call a virt or soft ?
> exten => s,31,SetVar(VMBOX=${ARG1})             ; Virt, So vm is the same
> exten => s,32,SetVar(TODIAL=${VIRT[${ARG1}]})   ; Grab the list of real exts
> exten => s,33,Goto(91)                          ; Jump to the dial routine
> exten => s,41,SetVar(VMBOX=20${ARG1:1:1})       ; Soft, So vm is the virt
> exten => s,42,SetVar(TODIAL=${ARG2}/${ARG1})    ; But it is a real ext
> exten => s,43,Goto(91)
> exten => s,91,Dial(${TODIAL},25,Tt)
> exten => s,92,GotoIf($[${ARG1:0:1} = 2]?93:94)  ; Do we need to handle vm ?
> exten => s,93,GoSub(s-${DIALSTATUS},1)
> exten => s,94,Hangup()
> exten => s-NOANSWER,1,Voicemail(u${VMBOX})      ; Virtual extensions have
> exten => s-BUSY,1,Voicemail(b${VMBOX})          ; VM, so transfer caller
> exten => s-CHANUNAVAIL,1,Voicemail(u${VMBOX})   ; Offline, so transfer call
>
> I have a dialplan where 1xx are real extensions, with no voicemail,
> 20x are virtual extensions, identified with an induvidual, with voicemail, and
> 2xy are extensions assoiated with the same induvidual as the virtual
> number (ie 21x are all linked to 201 etc..)
>
>
> HTH
>
> Iain
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>



More information about the asterisk-users mailing list