How to capture the result of Dial command

After hours (days) of trying things I finally figured out I can at least view the results of a dial (DIALSTATUS) by prefacing the dial command with Set(CHANNEL(hangup_handler_push) but I want to capture the DIALSTATUS and act accordingly. The docs say I can specify an argument to the subroutine but aren’t clear about how to write it.

What arguments are you wanting to push to it? Since it executes on the channel you can access dialplan variables, such as DIALSTATUS, like you normally would without passing arguments.

I’d also suggest specifying what exactly you are trying to achieve in the end without talking about the implementation details.

I want to check the DIALSTATUS variable after the Dial command ends and make a decision based on its value. The Verbose command doesn’t work after the dial command for some reason so I’m not really able to tell if my decision code is correct. If I use Dial(PJSIP${EXTEN}}@xyz,45,g) and immediately follow it with Verbose($DIALSTATUS) nothing is displayed. All I’m really trying to accomplish is to test the decision making code following the Dial command. I hope I’m clear. Thanks

You were being asked why you need to check the DIALSTATUS after the Dial command, and the nature of the decision.

There are a number of missing characters in your code fragment (at least {, }, and /).

As it is a common misunderstanding, please confirm that you don’t need a successful status until after the call as ended, as Dial doesn’t terminate after dialing.

I think your last sentence confirms what is going on. I suspected the Dial was still in progress but the docs are misleading. They say there are 3 DIALSTATUS values [of interest] that can be returned. ANSWER, NOANSWER [in 45 seconds], and CONGESTION. If either of the last two are returned, I want to play a message telling the user instead of just bailing out. Thanks

You don’t need the g option for the last two to work, and they do work well. They will generally arrive in the main dialplan, not the hangup handler as there will have been no hangup on the A leg.

Thanks! I will give it a try.

Ok. I now have a working (simple) extensions.conf. But I have one question. I looked at the code but couldn’t see the answer. When the caller hangs up the phone [after a normal call], where does the hangup occur? It is plain to see that my code following the dial command is not being executed. Is there an implicit hangup inside the Dial application and then we exit the extension completely or does it finish the dial statement then somehow jump past the last “same” line and autofallthrough? Just trying to understand. Thanks to both of you for chiming in. It’s a fantastic piece of software.

If the caller hangs up, the call is already in a hungup state before Dial ends, as best I can remember. Dial tests for this and sets a non-zero return code if it finds it, and g isn’t used.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.