Launch EAGI from AMI

I am trying to understand how to request execution of EAGI using AMI .

I have an extension with agi:async started and I need to request for eagi process to start on it.

I am unable to find documentation on how that can be done.

The only thing you can do from AMI is to redirect the channel to an extension in the dialplan that executes the EAGI dialplan application.

I agree with @jcolp , Originate action and Local channel

I think Joshua was suggesting ChannelRedirect on the original channel!

In my case, I have incoming call that reaches an extension, I need to run EAGI script to gather audio and do other things as well. If I begin with eagi, that channel is locked and will not execute anything until agi completes.
So I would like to use AMI to create another channel separately for EAGI and attach it to current channel.
If I originate another channel it is not connected to current one, so it has to be bridged, if you bridge it - it works but but you loose the ability to manipulate original channel, async agi goes out the window

It is just a nightmare, this thing… no matter what tools you use ARI, AMI, AGI whatever…

How do you originate a call with AMI and attach it to live channel and have it only capture incoming sound.

Typically you would use chan_spy.

There is a more general low level mechanism, auidiohooks, but I’m not sure how well exposed it is in recent versions.

Once eagi starts it will not let the channel spy

It sounds as if you want to effectively create a fork of the media. In that case you’d originate a Local channel that spies on the channel, and then send the other half of it to EAGI. That would pipe the spied media into EAGI.

Then the original channel is locked by eagi and cannot execute async agi requests.
Spying channel is locked by spy command and cannot execute it either

And since we cant execute request spy or eagi using any interface in this situation it is a pretty very sad story.
One thing is clear if you want parallel processes - run parallel channels, but if you want to listen in - one thing at a time.

I still do not understand why bridged channels stop agi requests from AMI

They would both have to run on the same thread.

You can’t fundamentally have two or more owners of a channel - because then, who is right and who is wrong? Who is the real owner? Technically both of them, and then you get a clash.

As for your response - if you use a Local channel with Chanspy and EAGI then what you are stating doesn’t happen. That’s because a Local channel creates 2 channels, one which in this case would be executing Chanspy and the other which would be executing EAGI. People use this to do such things as play back a sound file to a channel while they are doing something else (like while talking to someone else).

The original channel doesn’t have EAGI executed on it at all.

If you do actually need EAGI on the original channel, then yes you are correct. You can’t do that for the reason I stated initially.

Thank you for the explanation Jcolp.
I think that ownership issue could be resolved with simple “ownership” setting being part of the bridge initiation command, but what you say does make a lot of sense.

I will try to do what you suggested, the issue I see is that when I originate a channel that has EAGI I see two channels connected but the system never gets to chanspy within the extension because eagi is always first and it runs entire length of the call.
I know that in AMI when originating I can send playback or other application requests but I could not find documentation where chanspy is an option

exten => play,1,Answer()
exten => play,n,EAGI(eagi.php)
exten => play,n,Verbose(Spying to: ${CALL_CHA})
exten => play,n,ChanSpy(${CALL_CHA},qw)
exten => play,n,Hangup()

You wouldn’t use it like that. Have you used a Local channel[1] before? It creates two channels. One side enters the dialplan and can execute ChanSpy. The other side (using Originate) can go into the dialplan or execute an application.

Example:

[chanspy]
exten => s,1,Answer()
exten => s,n,ChanSpy(${CALL_CHA},qw)

[eagi]
exten => s,1,Answer()
exten => s,n,EAGI(eagi.php)

You would originate to Local/s@chanspy and then in the Originate have it go to the s extension in the eagi context.

The first half would execute Chanspy, the second half EAGI. Since there’s two channels there are no concerns or problems with ownership or doing two things at once on a single channel.

[1] https://wiki.asterisk.org/wiki/display/AST/Local+Channel

Although Asterisk internals have changed a lot since the version with which I’m familiar, ownership at least to be ownership by a thread, and there is no actual record, in the channel, as to which thread currently owns it.

Someone familiar with the recent changes may be able to say whether that is still true.

No, you originate once to a Local channel - completely separate from the real call. The real call never executes EAGI or Chanspy directly.

You really should experiment with Local channels and understand how they work, they are extremely powerful and people have used them to do very creative and interesting things.

I don’t know what you mean by discriminate audio. I believe there are options to Chanspy to control what you are hearing (inbound or outbound).

It’s pretty much the same.

What you see in the documentation is what there is. You likely want the ‘o’ option.

I got functionality that was causing issues resolved and will move forward.

Jcolp I really appreciate your help, your input is massive help and I appreciate work you do here, I think many others do as well.

Thank you :grinning:

A post was split to a new topic: EAGI Usage with audio