Programatically creating and linking 2 channels

Hi all,

I have a problem I can’t seem to find a solution to. What I would like to do is have Asterisk call one phone (create one channel) and then have an AGI script run when that call is answered. This is not a problem. Then depending on what happens in the AGI I want to call another phone which I can do using the DIAL cmd. However, DIAL links the 2 channels when the second call is answered.
My problem is I want to be able to run a second AGI script on this second call before linking the 2 channels/calls together.
Does anyone know how I could accomplish this? Is there a way to create 2 channels and run AGI scripts on each and then link/connect them?
I should mention that I am using asterisk-java to do all this and that there is no actual calls coming into a dialplan. I am using DefaultAsteriskManager.originateCall(Originate) to cause Asterisk to call my first number and set the AGI I want to run.

Any and all help would be much apprectaited even if you are not familiar with asterisk-java.

Thank you,

Ok, I’m am getting further along on a solution except I still have a little problem…
My AGI script is issuing a Dial cmd to call the second party. In this Dial cmd I need to use both the ‘D’ (send DTMF upon answer) and ‘M’ (Macro) options in that order. Here is the output in Asterisk’s CLI for the Dial cmd (with certain info replaced with ‘’):

– AGI Script Executing Application: (Dial) Options: (IAX2/<IAX_account>/<phone#>|20|D(<phone_ext>)M(<Macro_name>))

My problem is the ‘M’ (Macro) option is being executed first, before the ‘D’ (SendDTMF) option. I need the DTMF sent before the Macro runs.

Does anybody know how I can do this??? Please HELP


k, got a solution working… I’m just sending the DTMF from the AGI first thing that my macro is calling.
Man… I’m a rookie to Asterisk…
I thought someone here would be able to help me out.
I hope this helps somebody in the future.