Cancel call created with AMI Originate

Hello,

I am wondering if there is an easy way to hangup a channel created with Originate?

What I do is following:

  • Call in dialplan triggers Agi;
  • Agi starts AMI: Originate with Channel “Local/@queue/n” in Async mode. A variable stores the incoming channel to be used to bridge the call at answer. Dialplan is modified to invoke ‘Dial SIP/’;
  • Agi plays announcements with streamFile;

Now the extension rings and the announcement is played to the calling party. At answer I can bridge the channels. But, if the calling party leaves the call before the call is answered, I would like to stop the outgoing call. When I send AMI Hangup with Channel “Local/@default”, an error is returned stating the channel is not found. The CLI trace shows:

-- Executing [queue@queue:9] Dial("Local/xxx@queue-00000031;2", "SIP/xxx@aaa.bbb.com,,eA()M(queueAnswer)t") in new stack

== Using SIP RTP CoS mark 5
– Called SIP/xxx@aaa.bbb.com
– Playing ‘/usr/opensips/sounds/netzws/id_1_wartezeit_ueberschritten’ (escape_digits=) (sample_offset 0)
– SIP/aaa.bbb.com-000000d9 is ringing
[May 24 13:38:58] NOTICE[9511]: manager.c:3312 action_hangup: !!! Can’t find channel to hang up!

I am aware that asterisk extends the channel name with an id (-00000031) and therefore there is no match on the channel name. The only solution I have atm is to send an CoreShowChannels action to asterisk and filter out the channel I would like to hangup, but I was hoping that there is a simpler solution…

Thanks in advance!

I cannot make sense of this unless I substitute Called for Calling. Even then, I can’t work out what advantage it offers over simply using the various options on Dial to do things on the called channel.

In that case, I can see no point in using AGI.

As the dialplan fragment knows a unique key, the channel name of the first party, you could simply get it to store its channel name in a global variable, modified by the name of the first party channel, or you could monitor the AMI events, to work out when the channel was created.

The construct using Origin to make outdails is used to control the incoming side and outgoing side individually: the calling party hears an announcement, during which call attempts are made to reach a number (or numbers sequentially). MusicOnHold is not an option because I need several announcements to the incoming side and be able to answer the call after a specific time while playing announcements.

What I would need is to store the outgoing Channel ID in a global variable and use this at release from the calling party, but I don’t see how this could be accomplished.

Sounds like the Queue application to me (with a simple, linear, search strategy).

To set a global variable use Set(GLOBAL(variable)=${CHANNEL})

The name of variable can include the value of other variables.