[asterisk-app-dev] WebSocket Stasis Control Best Practice

Matthew Jordan mjordan at digium.com
Mon Jun 16 08:51:09 CDT 2014


On Sun, Jun 15, 2014 at 9:24 PM, Krandon <krandon.bruse at gmail.com> wrote:

>  Hello Asterisk friends,
>
> I am currently interfacing with Asterisk through ARI and loving the
> experience so far. I have successfully originated calls and dumped them
> into my Stasis app. I am trying to figure out what the best way is to send
> a channel into an Application. The current architecture for
> /channels/{id}/play works well for the majority of my app, but I am running
> into a block figuring out how to interact with Asterisk dialplan
> applications.
>
> To give an example - I submit an originate to go to SIP/vendor/phoneNumber
> - with the other leg going to App: myStasisApp, {"soundFile":"blah"}. That
> works fine (with the proper quote escaping). Now my Stasis app has received
> the channelID to which we can do a lot of neat stuff. Say I play a sound to
> the user but then want to call the app WaitForSilence. What's the best way
> to do this? I may be misinterpreting the intended use of both Stasis and
> ARI - but I am curious to see what your thoughts are.
>
> Also, for the stasis app to get a list of arguments, I am passing it
> through as JSON. So far that is working fine - but I wanted to see if there
> was a better way to get a list/array of app args to Stasis.
>
> Forgive me if there is an easy solution - through digging and poking the
> last few days, I have not been able to find the intended use case or even a
> use case.
>
>
>
Well, the solution for this just got added into the Asterisk 12 branch, and
so it hasn't made it into a release yet. It should be coming soon in
Asterisk 12.4.0.

The TALK_DETECT [1] function enables AMI/ARI events [2] [3] [4] [5] on a
channel, such that a connected ARI application receives notifications over
the WebSocket when a person starts/stops talking. This lets you
asynchronously 'know' when both talking/silence has occurred - obviating
the need for the WaitForSilence/WaitForNoise dialplan applications. Plus,
because it is asynchronous, if you decide you don't *want* to wait for
silence, you don't have to!

With a bit of manipulation, you could also construct AMD from this as well
- but I'll admit that's a bit more challenging. I'd be interested in
people's experiences with attempting to do that, and if an asynchronous
"IS_HUMAN" detection function is needed or not.

[1]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+Function_TALK_DETECT
[2]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+ManagerEvent_ChannelTalkingStart
[3]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+ManagerEvent_ChannelTalkingStop
[4]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+REST+Data+Models#Asterisk12RESTDataModels-ChannelTalkingStarted
[5]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+REST+Data+Models#Asterisk12RESTDataModels-ChannelTalkingFinished

Matt

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-app-dev/attachments/20140616/9a96e214/attachment-0001.html>


More information about the asterisk-app-dev mailing list