简体   繁体   中英

How to handle channels into an ARI queue app?

I`m trying to play a little bit with ARI in order to create a queue that would be capable to serve multiple asterisk instances. After some basic documentation, it seems that ARI is the way to do it.

What I have achieved by now it`sa simple dial plan that sends an incoming call to my stasis app. Once the call came into stasis a STASIS_START event is fired, and I consider this as being the entry point to my queue (that is my first problem). After the call was received I put some records into an H2 database and start playing moh on that channel.

Just for the demo, immediately I try to create another channel to a free agent to handle the call.

The problem is that when I create the channel I have to set the app, and if I set the same app, I will get a new STASIS_START event fired(another entry in H2 DB - which is not desired), but in this case, it's a fake one, as I considered that STASIS_START should be fired only when a new call came into my "queue". I was thinking to put some variables on the "true external calls" that enter the stasis app and then check if the arrived calls have these variables... but I'm afraid I`m doing something wrong maybe from an architectural point of view.

What is the best approach here?

Another two bonus questions:

  1. Why would I use a bridge to play MOH for the waiting caller when I can play some moh directly on that channel? Is it because the bridge gave me the ability to record or capture DTMF events?

  2. Is my assumption correct that when I m trying to call for queue agents (in order to match these with the waiting call in the queue) I should use POST /channels/create combined with POST /channels/{channelId}/dial instead of using POST /channels` which would use originate?

I am not the best ARI programmer in the world, but on the matter of your code calling stasisStart() the second time I believe pretty much you only have the following two options:

  1. Yes, implement your original idea of a global variable to mark the first time stasisStart is called and bypass it every time afterwards. I tried this approach and it is working very well for me.
  2. If you can arrange your scenario in such a way that the first agent to answer is considered one phone call and the transfer to the next agent is considered a new phone call (albeit with the same caller channel) then you might be able to divide your code in two ARI apps, both running registered to stasis at the same time, where agent1 answers the call with app1 and then transfers the call to app2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM