Can't get DIALSTATUS on call end

Hello.
I want to send sms to callee when he dont answer call.
I have this code
[macro-send_sms]
exten => s,1,NoOp(ARG1 is: ${ARG1})
exten => s,n,Dial(${ARG1})
exten => s,n,GoToIf($[${DIALSTATUS}=“ANSWER”]:end?send_sms)
exten => s,n(end),NoOp(“All Good!”)
exten => s,n,Hangup
exten => s,n( send_sms),NoOp(“DIALSTATUS is :${DIALSTATUS}”)
exten => s,n(send_sms),AGI(call my script with sms sending)
exten => s,n,Hangup

Script work’s fine.
But when i make call and and cancel it from caller or callee side, i don’t see in CLI(v5) any DIALSATUS output. Only see part before Dial.

I’m using sip_chan. Asterisk version is 20.4.0.

What I’m doing wrong.

Should be ?send_sms:end

although, unless ${ARG1} contains the g option, the end path will never be taken as Dial will return no-zero and the dialplan execution will stop, before the GoToIf.

You can only place a label once. Also, in many cases, spaces are significant.

ARG1 is just channel i using to make call its looks like SIP/mySipPeer/8${EXTEN:2}

Logic with GoToIF is correct in my case. If DIALSTATUS is ANSWER then i just Hangup,in all other cases i trying to send sms.

Space is apear there when i was editing post.

If i got it right i just need to do Dial with g option? Should be like this Dial(${ARG1}, ,g) ,right?

The syntax of the GoToIf is invalid.

It will never be reached if the call is answered.

There is no need to use g if all you do is hangup.

Also, if the the caller hangs up, there is no channel to continue in the dialplan. That includes the case where the caller cancel before the call is answered. You would need a hangup handler to gain control in such cases (or the h extension).

Thank you for help. I create hangup handler and it works fine.

I just don’t understand one thing why GoToIf should be like this GoToIf($[${DIALSTATUS}=ANSWER]:send_sms?end)
I thougt that if condition is True then we go send_sms if it False we go end.
Am I missing something?

Yes, you invert symbols: should be GoToIf($[${DIALSTATUS}=ANSWER]?send_sms:end)

Ir should be ?end:send_sms

Yeah i got it. Thank you for help guys!

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