Re-routing failed calls

Hello community!,

I was trying to figure out if there is a way to re-route failed calls instead of just hanging up them

I know that there is a specific variable: DIALSTATUS that takes part of the DIAL command, but i dont know how to use it correctly :frowning_face:. (Maybe i am wrong…)

A exten => example would help a lot

Best regards!

There is an example, in the sample extensions.conf, of rerouting to voice mail. SImply replace voice mail by Dial.

In practice, you may want to look at HANGUPCAUSE, as well.

@david551
I found the example:

[stdexten]
${ARG1} - Device(s) to ring

exten => _X.,n,Set(LOCAL(dev)=${ARG1})

exten => _X.,n,Dial(${dev},20)

I dont really get the idea :frowning_face: (Maybe this wasn’t the example)

If my first post was not clear, then let me give a example

Lets say that i have 2 gateways,
GW 1 = Less cost but less prefixes to dial
GW 2 = High cost and dials everything

You know where this goes

Im trying to Dial always to GW1, but, if it does not take the call, then, i need to re-route the call to GW2

This code isn’t tested, it’s just an example.

exten => s,1,dial(gateway1/${ARG1)
same => n,Gotoif($[${DIALSTATUS} : "CONGESTION|CHANUNAVAIL"])?GATEWAY2
same => n,playtones(busy)
same => n,busy(16)
same => n,Hangup()
same => n(GATEWAY2),Dial(gateway2/${ARG1})