How to make a failover in a dial plan?

Hello all !

I have two service providers to call out. One is cheaper and I want to try this one first on every call, but if for some reason the call couldn’t be done, I would like to try the second service provider.

Could you give me a hint how to do it ?

Here is what I have :

exten => _0.,1,Dial(sip/33${EXTEN:2}@Keyyo)
exten => _0.,n,Dial(sip/33${EXTEN:1}@OpenIP)

Of course this would make that every call is done twice, could you help me to make the check so that I jump over the second one if the first came through?

Thanks a lot for any support !

Regards,
Fabianus

Hi, I have the same issue, I installed Asterisk 1.6 and Asterisk Gui 2.0, but I want to configure 2 trunks simultaneously, so if I dial 9 and the default line is busy in an other call, it automatically fallback to the secondary trunk.

No, the second Dial starts only if the first Dial fails, when Dial succeeds the execution of the dialplan stops.

Cheers.

Marco Bruni
www.marcobruni.net

This is actually quite fiddly to do unless you don’t mind the called phone ringing twice for unanswered calls. Answered calls are no problem; the dialplan will stop when the call succeeds, at least for 1.4 upwards.

You really need to look at ${HANGUPCAUSE} and work out which ones represent local problems and which ones are problems with the destination subscriber. This will depend on the technology used for the call, and you may still find that there are ambiguous cases.

For SIP, you should also use qualify on the trunk to avoid wasting time when the first one has been down for some time.

I am new to asterisk so try to bear with me. I am using asterisk 1.6 + Asterisk Gui 2.0, and this is the output of the extension.conf file. Let me tell you a bit about what I have and what I want to do.

I have 2 FXS and 2 FXO, so I have to analog phone lines and two analog phone devices. What I’d like is to fallback automatically to the secondary analog phone line if the default is busy.

What I have configured so far is:

1.- When I dial 9, I get the first phone line:

exten = _904XXXXXXXXX!,1,Macro(trunkdial,${trunk_2}/${EXTEN:1},${trunk_2_cid})
comment = _904XXXXXXXXX!,1,Mobiles 1,standard

2.- When I dial 91, I get the second phone line

exten = _9104XXXXXXXXX!,1,Macro(trunkdial,${trunk_1}/${EXTEN:2},${trunk_1_cid})
comment = _9104XXXXXXXXX!,1,Mobiles 2,standard

So as you can see it is not automatic, what I understood from the explanation above is that I would have to substitute the configuration of each trunk for one configuration, correct me if i am wrong:

exten = _904XXXXXXXXX!,1,Macro(trunkdial,${trunk_2}/${EXTEN:1},${trunk_2_cid})
exten = _904XXXXXXXXX!,2,Macro(trunkdial,${trunk_1}/${EXTEN:2},${trunk_1_cid})
comment = _904XXXXXXXXX!,???,Mobiles,standard

Thanks for your help!!!

Regards,

Carlos V.

Dear mbruni,

I did not see your answer till now … and it is the solution !

Thank you very much !

Yours,
Fabian

exten = _904XXXXXXXXX!,1,Macro(trunkdial,${trunk_2}/${EXTEN:1},${trunk_2_cid}) exten = _904XXXXXXXXX!,2,Macro(trunkdial,${trunk_1}/${EXTEN:2},${trunk_1_cid})

Firstly both cases should have used ${EXTEN:1}. = should be =>

The problem with a simple approach, like this, is that it will ring the phone twice if the callee was simply not there, which will annoy the callee, as they will see two missed calls for every one real missed call. Similarly for other subscriber, rather than network, failures.

What I was saying was that, to make this work smoothly, you need to check the reason for failure, to see if it was likely to be a network one, before trying the alternative routing. That’s non-trivial, because Asterisk doesn’t provide it in a clear manner.