Help with dialplan and valid DIALSTATUS

Hi everyone

I have a problem with my dialplan:
exten => _X.,1,Set(CHANNEL(hangup_handler_push)=outbound-hangup,s,1(args);
same => n,Dial(SIP/halonet/${EXTEN},30)
same => n,Wait(1)
same => n,UserEvent(DialStatus,status: ${DIALSTATUS},serial: ${SERIAL})
same => n,Hangup()

exten => ANSWERED,1,Answer()
same => n,UserEvent(AnswerConfirmation,serial: ${SERIAL})
same => n,Hangup()

exten => s,1,UserEvent(DialStatus,status: ${DIALSTATUS},serial: ${SERIAL})
same => n,Return()

I use it to talk to my WebService through AMI interface. I originate a call by issue following AMI action:
Action: Originate
Channel: Local/@outbound
Context: outbound
Priority: 1
ActionID: 1
Variable: SERIAL=

Asterisk makes a call and pushes my events to my EventListener written in Java (Asterisk-Java), up to this everything as I expected then I have a problem that when I reject incoming call on my mobile phone Asterisk populates ${DIALSTATUS} with value BUSY. As I have read in documentation it should be populated with the DONTCALL value is not it? Next attempt when I just call my mobile phone while it’s busy doing another conversation for example to my friend it populates again the same value BUSY. As I can accept one of them but not both because I cannot recognize which one is real BUSY and which one is DONTCALL. Also I don’t get NOANSWER value when I just leave the phone ringing for some time instead I get CANCEL it should not be like that right? Only one of the status I get I think correctly is ANSWER value when I just pickup the phone.

My requirements which I need to support is:

  1. Recognise four of DIALSTATUS values: answer, busy, noanswer, dontcall and pushes them to my UserEvent on AMI
  2. Just after user pickup the phone Asterisk should hangup the call and just return DIALSTATUS
  3. When user don’t pickup for some time it should also hangup and return valid DIALSTATUS
  4. When user reject the call it should be valid DIALSTATUS also
  5. And last use case is when Asterisk found that user number is busy just return BUSY

The question is, is it possible and how to do it? Please help me.

About my configuration:
AsteriskNOW 6.12 64bit directly from site, registered SIP provider as follow:


The DONTCALL dial status is used if privacy and screening mode is enabled with app_dial usage. It is not set from an external source. From our perspective we likely receive that the dialed number is busy. As for CANCEL we would need to see the complete console output and SIP log (sip set debug on) to know exactly what is going on.

So there is not chance to distinguish between the two (user is busy and user rejected the call) ?
My SIP provider returns both status properly (when user is busy and when the call is rejected) so how to make it on Asterisk side ? I need that status please help me.

There is hangup cause[1] functionality but as you haven’t provided more information I don’t know if it would help you.