Hi batrams
It is best to handle this with Dialstatus as You will find that your supplier will be responding with Busy for Busy and Congestion when their network is congested or OOO.
First thing is to Noop the dialstaus of all types of calls then add the the coresponding call handling, some suppliers and gateways differ
The following context works with my IAX and sip suppliers. It also allows users to wait on music is the number is busy.
[code][timeout]
exten => s,1,Goto(s-${DIALSTATUS},1) ; This gets the dial status
exten => s-NOANSWER,1,Playtones(congestion)
exten => s-NOANSWER,n,wait(10)
exten => s-NOANSWER,n,Hangup()
exten => s-CHANUNAVAIL,1,Playtones(unobtainable)
exten => s-CHANUNAVAIL,n,wait(10)
exten => s-CHANUNAVAIL,n,Hangup()
; If a destination is busy the call may press 5 or wait and the call will be queued
exten => s-BUSY,1,Playtones(busy)
exten => s-BUSY,n,Set(TIMEOUT(digit)=1)
exten => s-BUSY,n,WaitExten(5)
exten => s-BUSY,n,Set(redialtime=30)
exten => s-BUSY,n,Goto(s-CAMPON,1) ; If users press 5 the call is requeuded
exten => s-BUSY,n,Hangup()
exten => s-CAMPON,1,NooP(${redial}) ;This is the number dialed
exten => s-CAMPON,n,NooP(${cont}) ;This is the Context of the call
exten => s-CAMPON,n,NooP(${redialtime})
exten => s-CAMPON,n,waitmusiconhold(${redialtime})
exten => s-CAMPON,n,Dial(Local/${redial}@${cont})
exten => s-CONGESTION,1,Playtones(congestion)
exten => s-CONGESTION,n,wait(10)
exten => s-CONGESTION,n,Hangup()
exten => 5,1,Noop(${EXTEN})
exten => 5,n,Set(redialtime=15)
exten => 5,n,Goto(s-CAMPON,1) ; If users press 5 the call is requeuded
exten => _5.,1,Noop(${EXTEN})
exten => _5.,n,Set(redialtime=${MATH(0${EXTEN:1}+10)})
exten => _5.,n,Goto(s-CAMPON,1) ; If users press 5 the call is requeuded
exten => i,1,Playtones(switching)
exten => i,n,wait(10)
exten => i,n,Hangup()
exten => t,1,Playtones(switching)
exten => t,n,wait(10)
exten => t,n,Hangup()
[/code]