How to check the result of the Dial application

I am running 16.1. I have a simple dialplan extension with 2 lines
same => n,Dial(PJSIP/${EXTEN}@anveo,45)
same => n,Hangup()

I want to detect when/if the dial application ends with sip code 603 and play a message to the person who dialed. I can’t figure out where/how to detect if the end reason code is 603.

The DIALSTATUS dialplan variable can be used for a basic level and the HANGUPCAUSE dialplan function can be used to drill down including to the protocol level[1].

[1] https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause

Ok, It looks as though DIALSTATUS is partially working but when the line is busy I seem to get NOANSWER. While a busy is almost the same as NOANSWER, shouldn’t I get BUSY? I’m thinking I need to ignore busy with possibly letting the caller hear a busy signal. I thought I had heard a busy signal before but now I am wondering.

That depends upon how exactly busy is communicated. If it’s signaling based, then it would show as busy. If the busy is as audio then it would not.

I don’t seem to be getting consistent results. I’m guessing I don’t have the syntax correct. Something with brackets and/or quotes""…

same => n,Set(rcode=${DIALSTATUS})

same => n,GosubIf(${rcode} != ANSWER?PlayMessage,s,1)

GotoIf(${rcode} = NOANSWER?3:6)
etc …

edited I think I figured it out. Needed to enclose the conditional statements with another $[ and ] before the question mark.
Question: Would a space before the question mark have worked just the same?

The Sample Configurations that come with Asterisk have a use of DIALSTATUS in them.

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