I would like to know if there is a way to add to Originate via AMI hangup handlers or pre dial handlers, so for example if I use originate using channel, exten and priority I can only add hangup handlers if the call is answered so those failed, busy, No answer wont go through dialplan.
I found a way to do somthing similar to what I need It will take more work from the dialplan but if I add in manager.conf setvar option I can push the hangup handler there and works
I am not sure if prefixing the variable for inheritance purposes will work in an extra setvar line within manager.conf, but adding a DumpChan() into your OriginateHangup context might help you see what you do have available when the call gets there.
Another option is to hack in some state tracking via internal Asterisk DB, keyed by the unique ID of the call, with some occasional garbage collection for stale states.
variable inheritance doesn’t work as they are only added to the second call leg (once connected the originate action), standard basic variables is what I have there.
Using Asterisk DB is a workaround that I prefer not to use becuase of performance
other important issue is that if I use setvar in manager.conf the variables that I add in the originate AMI action are not setted I’ve found in manager.c what seems to be the problem: