Roll on failure to secondary SIP termination

We have two SIP providers. The primary is way cheaper than the secondary, but they sometimes have call completion issues. Right now, our dialplan includes:

[code]; Outbound to primary sip
exten => _ZXXZXXXXXX,1,Dial(SIP/${EXTEN}@outbound)
exten => _ZXXZXXXXXX,n,Hangup

; Outbound to secondary sip
exten => _2ZXXZXXXXXX,1,Dial(SIP/${EXTEN:1}@outboundalt)
exten => _2ZXXZXXXXXX,n,Hangup
[/code]

What I’d like is that it try to complete the call on outbound, and if it fails, attempt it on outboundalt. How can I do this? Seems like something I’d have been able to find with Google, but I haven’t. A link to a resource would be just fine if you know of one.

I just dial the first one, and if there’s a problem it drops through to the next priority of the dial plan, if the call completes, it won’t, because it hangs up when the call is finished. So essentially all you need is.

exten => _ZXXZXXXXXX,1,Dial(SIP/${EXTEN}@outbound)
same => n,Dial(SIP/${EXTEN:1}@outboundalt)
same => n,Hangup()

Dial also returns status so you could check for various things if you like.