This should do what you want:
You can call it like this:
exten =>
12125551212,1,Macro(dialoutbound,${EXTEN},8005551212,3-Zap/G1/-Zap/G2/-Sip/Nufone/)
The above using the macro below will try zap/g1 first if it's in use
or otherwise unavailable, ti will go to zap/g2 and then sip/nufone.
[macro-dialoutbound]
;arg1 number to dial
;arg2 callerid
;arg3 device in form of: devicecount-device/resourc-device/resource as
many as matching devicecount
;when busy it will play busy
;when channelunavail, it will play congestion
exten => s,1,Noop()
exten => s,2,Noop()
exten => s,3,Noop()
exten => s,4,GotoIf($[${LEN(${CALLERID(num)})} > 7]?100);if we got cid
longer than 7 then it's an outside number so we leave it
exten => s,5,Set(CALLERID(num)=${ARG2})
exten => s,6,Goto(10)
exten => s,10,Noop()
exten => s,11,Noop(Weare starting to cut)
exten => s,12,Set(DCNT=${CUT(ARG3,,1)})
exten => s,13,Set(CNT=2)
exten => s,14,Goto(50);thats where we assign the DVC var
exten => s,50,Noop(We start assigning devices)
exten => s,51,Noop()
exten => s,52,Set(TCNT=$[${CNT} - 2])
exten => s,53,GotoIf($[${TCNT} = ${DCNT}]?800);congestion
exten => s,54,Set(DVC=${CUT(ARG3,-,${CNT})})
exten => s,55,Set(TCNT=${CNT})
exten => s,56,Set(CNT=$[${TCNT} + 1]);here we increment it
exten => s,57,Goto(callme,1)
exten => s,100,Noop(not setting CID, since we got one)
exten => s,101,Noop()
exten => s,102,Goto(10)
exten => s,800,Noop()
exten => s,801,Congestion()
exten => s,802,Hangup()
exten => callme,1,Noop()
exten => callme,2,Dial(${DVC}${ARG1},,Ww)
exten => callme,3,Goto(${DIALSTATUS},1)
exten => callme,103,Goto(3)
exten => CHANUNAVAIL,1,Noop()
exten => CHANUNAVAIL,2,Noop()
exten => CHANUNAVAIL,3,Goto(s,50)
exten => CONGESTION,1,Goto(CHANUNAVAIL,1)
exten => NOANSWER,1,Goto(s,800)
exten => BUSY,1,Noop()
exten => BUSY,2,Noop()
exten => BUSY,3,Playtones(busy)
exten => BUSY,4,Busy()
Hope this helps.
On 7/24/07, Vieri <rentorbuy at yahoo.com> wrote:> Hi,
>
> I'm trying to set a rule to dial out through multiple
> Zap groups so that, say, g0 is the cheaper POTS lines
> group
> and must be used first. However, if g0 is busy or
> disconnected then try dialing out g1.
>
> My g0 group is made up of 4 analog lines connected to
> a 4-FXO card. I disconnected the RJ-11 wires from the
> FXO card
> to simulate a line disconnection. So theoretically all
> calls should immediately go out through g1 but they
> don't.
> They get "stuck" on g0 as I can see in the asterisk
> CLI:
>
> -- Executing Dial("SIP/4053-082393a8",
> "ZAP/g0/555555555|120|TWm") in new stack
> -- Called g0/555555555
> -- Started music on hold, class 'default', on
> SIP/4053-082393a8
> -- Zap/32-1 answered SIP/4053-082393a8
> -- Stopped music on hold on SIP/4053-082393a8
> (endless)
>
> Note: Zap channel 32 is part of g0.
>
> I used both FreePBX and a custom made rule.
> With FreePBX, the outgoing dialplan includes something
> like this:
>
> exten =>
> _5XXXXXXXX,1,Macro(dialout-trunk,1,${EXTEN},,)
> exten =>
> _5XXXXXXXX,n,Macro(dialout-trunk,2,${EXTEN},,)
> exten => _5XXXXXXXX,n,Macro(outisbusy,)
> ; trunk 1 is g0, trunk 2 is g1
>
> If I use a custom dialpan that looks something like
> this:
>
> exten => _5XXXXXXXX,1,Dial(Zap/g0/${EXTEN})
> exten => _5XXXXXXXX,n,NoOp(${DIALSTATUS})
> exten => _5XXXXXXXX,n,Dial(Zap/g1/${EXTEN})
> exten => _5XXXXXXXX,n,HangUp()
>
> and then watch the CLI, I get exactly the same
> behavior as above, ie. I don't get past
> Dial(Zap/g0/${EXTEN}) as
> Zap/32 answers when it shouldn't. And obviously I
> can't get ${DIALSTATUS} to eventually define some
> gotos because it's ANSWERED.
>
> Any ideas as to what I should try?
> Maybe change some setting in zapata.conf?
>
> Thanks
>
> Vieri
>
>
>
>
____________________________________________________________________________________
> Shape Yahoo! in your own image. Join our Network Research Panel today!
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
>
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>