Predial or Hangup Handlers on AMI originate

Hi,

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.

thanks

Originate to to a local channel.

I cant use local channels for this, but as this creates a channel I suppose there should be a way to push a hangup handler for it?

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

ex: setvar=CHANNEL(hangup_handler_push)=functions,OriginateHangup,1

this kind of works, but I don’t have any variable that I put on the Originate Action, anyway kind of works for me

You can add arguments to hangup handlers:

https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

yes but I cannot use variables there (I tried)

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

thanks

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:

I think the if under the for is wrong and should be like this:

I agree that if(v->next) conditional is always false and should be removed. Good catch! You might consider filing a bug on the issue tracker.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.