Outbound Dialer over ARI

I am already on a stage where I can initiate a outbound call through a stasis application.
But I cannot achieve few things that I want to get help on.

To achieve an outbound call:

  1. I called originate on a sip peer registered on asterisk. (A zoiper extension)
  2. I called originate on sip trunk on my number.
  3. I created a bridge.
  4. Once I got StasisStart event on a channel I add that channel to that bridge. Same with other channel.

Now both the sip extension and my phone can talk to each other.

But what I want to achieve is that the extension should listen the ringing or the busy tone or whatever when user on the extension picks up the call…

Or in short I want to mimic the behaviour of an extension dialing out a sip trunk though Dial app in extension.conf.

For this I am using ari4java.
Any help regarding the process to achieve this will be appreciated. Thanks in advance.

If you want to bridge before the remote side has been answered this is only available as of Asterisk 14. It’s called early bridging. You can find some more information on a blog post[1] that was done about it, but I’m not sure if ari4java has support for it yet.

[1] http://blogs.asterisk.org/2016/08/24/asterisk-14-ari-create-bridge-dial/

Thanks Jcolp for the quick response.
I am still on asterisk 13 as it is the latest long term support version yet.

Is there any way where I can pass variables from my stasis application while returning to Dialplan?

Because if it is possible I can originate channel to internal SIP peer and as soon as the user picks up the call I can pass the external phone number in a variable to the dial plan to use standard DIAL app to dial an outbound call.

My stasis application will still be monitoring all the channels and bridges so if I want to take further actions on the bridge like a transfer for consult for a snoop I will be having bridge-Id to initiate that request.

I just want to know if this can work or not, given you can pass the local variables to dial plan ?

You can provide variables to the originate operation, or you can send the channel into your Stasis application and using the variables operation to set variables on it and then send it back into the dialplan.

Once the channel leaves your Stasis application you have limited control over it. You can initiate a snoop and hang it up. Maybe a few other things but that’s it.