How to play busy tones when called number is busy

I use a SIP provider, Asterisk 1.2.14 and X-lite. When I make a call to a number that’s busy, I see my server knows the number is busy:

– Got SIP response 486 “Busy here” back from 54.5.142.24
– SIP/outbound-032815f0 is busy
== Everyone is busy/congested at this time (1:1/0/0)

But what do I put in the dialplan to detect the busy condition and play the busy tone to the caller?

playtones(busy)

Yes, I get that part… but I don’t know how to tell the dialplan to detect busy condition. Any thoughts?

The correct way of doing this is the examine the dialstatus value, however I’m too lazy,

So my scripts run as follows

Dial
playtones(busy)
Congestion(15)
Hangup

If the call succeeds, it will exit non zero on the dial and not execute the rest. If it fails, then busy tones are generated.

Example using dialstatus

[macro-safedial]
exten => s,1,Set(DIALSTART=${EPOCH})
;exten => s,n,Dial(${ARG1},${ARG2},g,${ARG4})
exten => s,n,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s-CANCEL,1,Hangup
exten => s-NOANSWER,1,Set(DTIME=$[${EPOCH} - ${DIALSTART}])
;watch out: DIALEDTIME can also be empty, next line is not perfect!
;exten => s-NOANSWER,n,GotoIf($["${DIALEDTIME}" = “0”]?4)
exten => s-NOANSWER,n,GotoIf($["${DTIME}" = “0”]?4)
exten => s-NOANSWER,n,Hangup
exten => s-NOANSWER,n,Verbose(1,Need failover for “${ARG1}”)
exten => s-BUSY,1,Busy
exten => s-CHANUNAVAIL,1,Verbose(1,Need failover for “${ARG1}”)
exten => s-CONGESTION,1,Congestion
exten => _s-.,1,Congestion
exten => s-,1,Congestion

regards

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]

Thanks for the replies - I’ll give it a shot :smiley: