Asterisk DialStatus Channel Varriable
Asterisk channel variable DIALSTATUS
Contains a text string signifying result of the last dial attempt:
- ANSWER: Call is answered. A successful dial. The caller reached the callee.
- BUSY: Busy signal. The dial command reached its number but the number is busy.
- NOANSWER: No answer. The dial command reached its number, the number rang for too long, then the dial timed out.
- CANCEL: Call is cancelled. The dial command reached its number but the caller hung up before the callee picked up.
- CONGESTION: Congestion. This status is usually a sign that the dialled number is not recognised.
- CHANUNAVAIL: Channel unavailable. On SIP, peer may not be registered.
- DONTCALL: Privacy mode, callee rejected the call
- TORTURE: Privacy mode, callee chose to send caller to torture menu
- INVALIDARGS: Error parsing Dial command arguments (added for Asterisk 1.4.1, SVN r53135-53136)
The dial status may be used in the dialplan to control program flow, see example in goto documentation.
Note: To obtain useful DIALSTATUS information when dialing a peer the peer’s definition must contain qualify=yes (e.g., in sip.conf or iax.conf).
- CONGESTION “Congestion” is somewhat misleading. Unfortunately at this time (2007-05-17), Dial() returns DIALSTATUS=CONGESTION for pretty much every call setup problem. The reason for this is that Dial() is used for multiple protocols (Zap,SIP,IAX etc.) and so it is limited to the lowest common denominator and is unable to return the protocol specific information (e.g., SIP 404 response) .
This macro is an example of how failover for two or more outgoing trunks can be managed
[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”]?here)
exten => s-NOANSWER,n,GotoIf($[“${DTIME}” = “0”]?here)
exten => s-NOANSWER,n,Hangup
exten => s-NOANSWER,n(here),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
The following is an example of a local Zap channel callout with SIP failover (ex. Zap channel is in use)
[macro-localcallout]
exten => s,1,Dial(${ZAP/1/${ARG1},,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Hangup
exten => s-CONGESTION,1,Congestion
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},,T)
[dialstatustest]
exten => s,1,Dial($
{TRUNK}
/0123456,30,g)
exten => s,n,Goto(s-$
{DIALSTATUS},1)
exten => s-NOANSWER,1,NoOp(hangup)
exten => s-NOANSWER,n,Hangup
exten => s-BUSY,1,NoOp(busy)
exten => s-BUSY,n,Hangup
exten => s-CHANUNAVAIL,1,NoOp(chanunavail)
exten => s-CHANUNAVAIL,n,Hangup
exten => s-CONGESTION,1,NoOp(congestion)
exten => s-CONGESTION,1,Hangup
exten => s-ANSWER,1,NoOp(answer)
exten => s-ANSWER,n,Hangup
exten => _s-.,1,Goto(s-BUSY,1)
[default]
exten => 0123456789,n,Goto(dialstatustest,s,1)
if DIALSTATUS = ANSWER Goto(s-${DIALSTATUS}
,1) jumps to _s-. instead of s-ANSWER
– Executing [s@dialstatustest:2] Goto(“DAHDI/31-1”, “s-ANSWER,1”) in new stack
– Goto (dialstatustest,s-ANSWER,1)
– Executing [s-ANSWER@dialstatustest:1] Goto(“DAHDI/31-1”, “s-BUSY,1”) in new stack
– Goto (dialstatustest,s-BUSY,1)
– Executing [s-BUSY@dialstatustest:1] NoOp(“DAHDI/31-1”, “busy”) in new stack
– Executing [s-BUSY@dialstatustest:2] Hangup(“DAHDI/31-1”, “”) in new stack