Zap channel failover when line is congested

I have two PSTN connected to two trunks via zap. If the first trunk is engage in a call, it doesn’t seem to failover to another trunk. Logs as per below and have masked the number I dialed.

– Executing [1-dial@macro-trunkdial-failover-0.3:1] Dial(“SIP/6001-003f0004”, “Zap/g2/9XXXXXXX”) in new stack

[Apr 9 18:56:42] WARNING[8052]: app_dial.c:1183 dial_exec_full: Unable to create channel of type ‘Zap’ (cause 34 - Circuit/channel congestion)
== Everyone is busy/congested at this time (1:0/1/0)
== Auto fallthrough, channel ‘SIP/6001-003f0004’ status is ‘CONGESTION’

Below is my configuration:

trunk_1 = Zap/g1
trunk_2 = Zap/g2
trunk_4 = Zap/g4

exten = _9XXXXXXX,1,Macro(trunkdial-failover-0.3,${trunk_2}/${EXTEN:1},${trunk_4}/${EXTEN:1},trunk_2,trunk_4)

exten = s,1,Set(CALLERID(name)=${CALLERID(name)})
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 1]?${CID_${CALLERID(num)}}:)})
exten = s,n,NoOp(${CALLERID(num)})
exten = s,n,MixMonitor(/persistent/sounds/record/${STRFTIME(${EPOCH},%C%y%m%d%H%M%S)}.wav,ab)
exten = s,n,Goto(1-dial,1)
exten = 1-dial,1,Dial(${ARG1})
exten = s,n,StopMonitor()
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()

Can help suggest what seems to be the problem? Thanks.

You have already asked on the correct forum, and I have already told you what is wrong, there.

Sorry, I am a newbie here. Can you please help simplify for me using the context I have provided if you don’t mind? Thanks.

I managed to make this work by adding two zap channels in a group and adding a global value in extensions.conf for this new group.