How can I setup the extensions.conf file

How can Isetup my extensions.conf file to redirect the call to other route when the first route return some error like SIP 503 and doesn’t complete the calls?

exten => _X.,1,Dial(SIP/carrier/${EXTEN},180/nj)

Look at the HANGUPCAUSE and then act.

I know the cause, my carrier is with problem to forward the call, but how can I redirect to another route, first passing in the this route?

I intend to use like a contingency route when the first doesn’t work.


Dial does not terminate the dialplan when the call fails. The call is left in essentially the same state as before the Dial, (except for setting DIALSTATUS and HANGUPCAUSE. You can call any application that you could have called at the point where you called Dial.

1 Like

Well, ok David,
But if the first route works correctly, the dialplan will not make the 2º path?

Unless you use the g option, DIal returns non-zero, which will terminate the dialplan after any h extension is run. If you want to be more precise, you must test the HANGUPCAUSE, as originally suggested.

Thank you David,
Can you show to me an example of the Dial plan testing the HANGUPCAUSE?

Adapt the examples for DIALSTATUS in the sample extensions.conf, or look at the FreePBX source code, as it does this. Potential values can be found by googling “ISDN Cause Codes”.

exten => s,n,GotoIf($[${HANGUPCAUSE}=34]?Provider2)

Thank you johnkiniston,

My actual DialPlan:

[rotadesaida-silver] ;Silver
exten => _+X.,1,Dial(SIP/voxbeam/${EXTEN:1},180/nj)
exten => _X.,1,Dial(SIP/voxbeam/${EXTEN},180/nj)
include = basico
include = incoming

With you change and for HANGUPCAUSE 503 should be stay:

[rotadesaida-silver] ;Silver
exten => _+X.,1,Dial(SIP/voxbeam/${EXTEN:1},180/nj)
exten => _X.,1,Dial(SIP/voxbeam/${EXTEN},180/nj)
exten => _+X,1,GotoIf($[${HANGUPCAUSE}=503]checkbox) ;where checkbox is my second carrier
exten => _X,1,GotoIf($[${HANGUPCAUSE}=503]checkbox) ;where checkbox is my second carrier
include = basico
include = incoming

I’d write it something like this:

exten => _+X.,1,Dial(SIP/voxbeam/${EXTEN:1},180/nj)
 same => n,ExecIf($[${HANGUPCAUSE}=34]?Dial(SIP/checkbox/${EXTEN:1},180/nj))
 same => n,Playtones(congestion)
 same => n,Congestion(30)
 same => n,Hangup()

where 34 is the SIP code of Error?


Thank you johnkiniston