Hangup issues

Hello,

I guess this is simple to resolve but I am still newbie on asterisk :smile:

i have this dial-plan. If the caller hang up the phone first, never goes to exten => s-ANSWER.
If the internal agent hang up before the caller,the dial-plan is working fine and executes s-ANSWER

What I need is to execute a curl only if-and-only the call is answered.

Thank you all for your kind support!

Regards,
Vangelis

[macro-uridial] exten => s,1,Answer() exten => s,2,Background(music); exten => s,3,Set(thedid=${SIP_HEADER(To)}) exten => s,4,Set(thedid=${CUT(thedid,@,1)}) exten => s,5,Set(thedid=${CUT(thedid,:,2)}) exten => s,6,Set(extredir=${CURL(http://www.xxx.com/restvoip.php?sid=7&bid=163&action=1&uid=${UNIQUEID}&cid=${CHANNEL}&num=${CALLERID(num)}&did=${thedid})}) exten => s,7,Set(i=0) exten => s,8,Set(i=$[${i}+1]) exten => s,9,Set(ext=${CUT(extredir,"~",${i})}) exten => s,10,GotoIf($["${ext}" = ""] ? 17:11) exten => s,11,Dial(SIP/${ext},15,g) exten => s,12,Wait(1) exten => s,13,Set(pseudodid=${DIALEDPEERNAME}) exten => s,14,Set(pseudodid=${CUT(pseudodid,-,1)}) exten => s,15,Set(pseudodid=${CUT(pseudodid,/,2)}) exten => s,16,Goto(s-${DIALSTATUS},1) exten => s,17,Background(no-available); exten => s,18,Hangup() exten => s-ANSWER,1,Set(extredir=${CURL(http://www.xxx.com/restvoip.php?sid=7&bid=163&action=2&uid=${UNIQUEID}&cid=${CHANNEL}&num=${CALLERID(num)}&ext=${pseudodid}&cabid=${ext}&di$ exten => s-NOANSWER,1,Goto(macro-uridial,s,8) exten => s-CHANUNAVAIL,1,Goto(macro-uridial,s,8) exten => s-BUSY,1,Goto(macro-uridial,s,8)