Run script after call with number and duration

Hi all,
I want to call a script after a call successfully ends with the number that called in ( or was called ), the extension that answered and the call duration.

I have something like the below, but it only fires if no one answers, and even them, doesn’t seem to always fire.

exten => s,1,Set(TIMEOUT(digit)=2) exten => s,2,Set(TIMEOUT(response)=10) exten => s,3,Dial(${EXT601}&${EXT602}&${EXT603}&${EXT604}&${EXT605}&${EXT606},20,r) exten => s,4,Set(foo=${CALLERID(num)}) ;; trying which one fires ... exten => s,5,System(php /etc/asterisk/_api_log_call.php?call=1 ${foo}) exten => s,6,System(php _api_log_call.php?call=3 ${foo}) exten => s,7,Set(result=${SHELL(php /etc/asterisk/_api_log_call.php?call=3 ${ARG1} ${CALLERID(num)})} ) exten => s,8,Voicemail(${HOMEVOICEMAIL}@default) exten => s,9,Hangup

Thanks

The h extension Gets executed after a call has been terminated. Note that as soon as this happens, the content of ${EXTEN} changes to h.

Thanks for your answer,

Can you give me an example of what you mean?
Google-ing “h extension” doesnt give me a solution.

Thanks

exten => h,1, System(/home/myscript.sh)

google.com.do/search?q=aste … 0gHioYDICg

And the number that called in ( or was called ), the extension that answered and the call duration. You can get that information on the Asterisk CDR, so could be better if your script extract that info from the CDR. I see that you are using PHP so could be useful if you check MySQL CDR Backend

wiki.asterisk.org/wiki/display/ … DR+Backend