Did you look in api_hangup_hook. You can call lua script with. Exampleset api_hangup_hook=lua sendmsg.lua