Hi Malcolm,
Thank you very much for your answer. You suggested to use the Originate application. I think that this is what I did, but I may have missed something. Here is what I achieved so far.
Bob (exten 101) calls Alice (exten 102) and he needs the help of an assistant during his conversation with Alice.
I wrote the following dialplan so that instead of dialing Alice directly, Bob uses a prefix (digit 6 here) to explicitly indicate that he requires assistancy.
exten => _6XXX,1,Answer()
exten => _6XXX,n,Playback(some_annoucement_here)
exten => _6XXX,n,Agi(agi://localhost/myscript.agi)
In myscript, in JAVA here, I wrote the following:
public void service(AgiRequest request, AgiChannel channel) throws AgiException {
String dest = request.getExtension().substring(1);
Callback cb = new Callback(this);
asteriskServer.originateToApplicationAsync("SIP/" + dest, "MeetMe", "600", 30000, cb);
// Go to conf room (synchronous call!)
channel.exec("MeetMe", "600");
}
I understood that Bob who initiated the call, was the channel to this script and therefore if I use a streamFile method on that channel, I am able to play an audio file to Bob.
The originateToApplicationAsync puts Alice into the conference room 600.
Then Bob has to join the conf room too so that he can speak to Alice. This is what the channel.exec method does. However, this call is a synchronous call, which means that when Bob joins the conference room, the script is suspended and therefore unable to play an audio file to Bob and Alice.
What would work here is an asynchronous call to a context^extension^priority instead of a SIP number so that I can bridge real people into the conference but agi scripts as well.
But maybe I am not doing things the right way… Could you tell me what is the correct approach to this?
Kind regards,
Gilles Gerlinger