How to catch when caller himself hangs up? [solved]

Hi. I am trying to implement asterisk in a CRM-system. I need to post some details to an url before an outbound call is made, and to post again after the call is finished (to update the DIALSTATUS etc).

The problem is: if the caller himself hangs up the call at any step, there is no way to do anything in the context after that. The system will be for salespeople who does outbound calls all day. I need a way to do something (preferably in the context) even if they hang up before there’s an answer in the other end. Here is an example dialplan:

exten => _NXXXXXXX,1,DOSOMETHING WITH CURL/MYSQL HERE)
exten => _NXXXXXXX,2,Answer()
exten => _NXXXXXXX,3,Dial(SIP/${EXTEN}@dev_out,15,jg)
exten => _NXXXXXXX,4,DOSOMETHING WITH CURL/MYSQL HERE, AFTER CALL ENDED)

This works in ONE case:
If the other person hangs up, AND the salesperson does not hangup himself before the call times out. He will in almost all cases hangup himself .

In all cases where the caller hangs up (even after the other part has), extension “exited non-zero”. I also want to be able to check if the salesperson has hung up even before call is initialized (DIALSTATUS=CANCEL), and then do something. None of this seems to be possible?

Is there a way I can do this? All help would be GREATLY appreciated!

This was solved using the ‘h’-extension

Try defining the h extension in the same context.