Asterisk dial fallback macro

If you have 2 or more outbound lines, and want to prioritize them, use this macro:

1
2
3
4
5
6
7
exten => 1234,1,Macro(dialWithFallback,555666)

[macro-dialWithFallback]
exten => s,1,Dial(SIP/line1/${ARG1})
exten => s,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?tryLine2)
exten => s,n,Hangup()
exten => s,n(tryLine2),Dial(SIP/line2/${ARG1})

In this case, 555666 will be called first on line1, and if it fails (channel unavailable), it will be called using line2.