Stasis App and channel switching

Hi all,

I am developing an application (App) for integrating Asterisk 13 with an external database.

At a high level, App works as follows.

  1. App establishes a Websocket connection with Asterisk.
  2. App catches incoming calls from a specific SIP trunk by means of a separate context in the dialplan with ‘Stasis’ application invoked.
  3. App parses JSON data received in the Websocket and gets caller ID (and other call attributes).
  4. App queries an external database and gets an extension this incoming call should be routed to.
  5. App switches the incoming call to the extension returned by the query to the database.

Items ##1…4 are already implemented and work fine. However, I need a solution item #5.

One obvious solution is to use Asterisk REST API (ARI) and implement switching logic directly in the App: create outgoing channel, create bridge, add both channels to the bridge.

However, this solution seems quite complicated and not efficient in terms of performance.

So, I have the following questions to the community:

Is it possible for Stasis to return some variable back to a dialplan and continue with channel switching by means of the dialplan itself instead of designing this switching logic in the App and invoke ARI calls?
If not, do you have any other suggestions for implementing item #5 in the above scenario without designing channel switching logic in the App?

Thank you a lot!

The continue[1] operation can be used to send a channel back into the dialplan at a specific location.



Thank you Josh.

So, still REST API, but in a simpler way that I originally was thinking of (create channel / create bridge / add channels to the bridge), right?

It’s REST API in that it is how you send it back into the dialplan, but once you do so then you lose control over the channel.

And one more generic question.

Stasis app has optional arguments:

As I understand, these args are passed from the dialplan to stasis app.
But is there any way to pass args from stasis app back to dialplan and use them in subsequent dialplan commands?


A dialplan doesn’t have arguments. Only dialplan applications do. The comparable thing would be dialplan variables which can also be set in ARI on a channel, and will remain if the channel is sent back into the dialplan.

Thank you, now it is clearer. Will try ContinueInDialplan and Redirect methods.

Hi @Pentium-5,

I am trying to capture the call attributes and send them in JSON format to an external application. Something similar to what you do in step 2, You could give me a hand?, how do you do in step 2?

thanks in advance,