Add multiple participants to Twilio conference - twilio-api

I am trying to move our existing call routing backend to conference to make advanced features available. Is there a possibility that I can take (1-1) simple calls that are going on, and place them inside a conference without loosing the connection? Basically I wanna be able to use conference only if specific features in conference (like whisper, barge) are required?
Or, do I have to start the call with the conference leg to be able to do this?
Here's what I've tried:
Start a simple Call from A - B (C1 -> call from browser client to twilio bridge, C2-> bridge to PSTN)
Call connects A to B for voice comms
If conference features are requested, I create new conference and try add both calls conference. It does work sometimes, but more often one of the calls ends up dropping.

Twilio developer evangelist here.
The issue you have with one call dropping as you move the other to the conference is that when you move that call, the other call then goes to the next TwiML verb (or the action attribute of a <Dial>). If there is no next TwiML to execute, then the call finishes.
The easiest way to achieve what you want here is to start in a conference.
If you want to achieve this with a 1:1 call first and then a conference, you will need to move the PSTN call first and provide more TwiML after your <Dial> so that the browser client has something to do until you can also move them to the conference. An example here could be to add a <Pause> after the <Dial> that would give you time to update the call using the REST API. Alternatively, if you know what the conference name will be beforehand, you could follow the initial <Dial> with a second <Dial><Conference> and the caller will be dropped straight into that conference as the other leg is moved.

Related

How to receive data from an api without any user interaction

I'm trying to receive some data from an API call and do some task based on the received data.
Let's say I have my flutter app opened and in that opened state without any click or any interaction I get some data or do any function when I send something through the API.
I used Firebase FCM to do such task - When I send something through the API the firebase notification captures that data and doing the tasks I want on the flutter app.
But I want to do without Firebase. How can I do that. Any solution/suggestions would be great. Thanks!
At first, let's put Flutter aside. Your problem is to pull data from API and do a specific task OR your API should notify the app through API.
For the first problem, a simple data polling should work: when the app is opened, you just start some kind of timer and periodically pull data from the API and do something. However, this method is not perfect, it drains the battery and in general, there are better ways to achieve the same thing, for instance using sockets or push notifications (as some of the answers already state that).
For your second problem - "or do any function when I send something through the API" - you need some kind of mechanism to notify your app for it to react and process the data. This one could be handled using the same mechanism as for the first problem.
So, probably you need to use some kind of push notification service (for instance OneSignal or Pusher, or any other similar service) or web sockets (https://flutter.dev/docs/cookbook/networking/web-sockets).
Your question is little bit unclear. Whatever if you want to do some network call even without any interaction by user you can call network in your onInit method. This method runs at the very beginning for individual screen. Then do your task based on the response
You need stream API for this,look into socket programming
You can use webs socket or pusher for this. When web socket is connected with your server that time you received some data and you can do your task.

Will OpenVBX and Twilio handle multiple calls and if one line is busy, go to the next line, etc

Can anyone tell me if my call flow below will work with OpenVBX & Twilio and if so, how to set this up there? I'm using Twilio with a trial number to test it out, but no luck so far. I have downloaded a plugin "OpenVBX-Plugin-Queue-master" that looks like it may work, but I can't get it to. I'm not a telephony expert. I am a programmer. =)
Here is what I need. I need to be able to receive multiple calls at the same time and move the caller to the next available attendants.
They need to hear the main greeting, press 1
Then go to the support group ideally (that is not working for me
right now either)- let's say attendant #1.
If attendant #1 is on the phone, put them on hold briefly listening
to another greeting, then send them to attendant #2
If attendant #2 is busy...repeat the process until I run out of
attendants and then they go to VM.
Here is my install version:
Current Version: 1.2.20
Schema Version: 79
Latest Schema Available: 79
Site Revision: 1026
Any help would be most appreciated!
Support for OpenVBX is not active at this time.
I'd suggest you take a look at the guide for Queues.
https://www.twilio.com/docs/api/twiml/guides/queues
Beginning with queuing your caller (an example in Ruby):
require 'sinatra'
require 'twilio-ruby'
# Handles the POST request from Twilio and generates the TwiML that puts caller in a queue.
post '/caller/?' do
response = Twilio::TwiML::Response.new do |r|
# Use <Enqueue> verb to place caller in a <Queue>
r.Enqueue "Queue Demo"
end
response.text
end
You can handle more sophisticated workflows like iterating through agents via TaskRouter.
And this Call Screening tutorial demonstrates how to handle agent voicemail with production ready code.
Please let me know if this helps at all.

Identify caller id, hung up, call back with asterisk

For a project I need to build an mvp of a service where users call a toll free number, on the other side, the pbx detects the call, saves the caller # and hangs up (so caller never gets charged for the call). Then the pbx calls the user back, allows him to dial a #, then pbx plays an audio file and when it finishes, makes the connection to the # introduced by the user.
I'm new to voip and asterisk, but which documentation should I read to achieve this (which features do I need to understand and look for?)
At begining you have to understand how to build dialplan and use it's applications(Dial, Playback and Read). If you want to use some programming language you can use AGI, there are library to write agi in almost all languages :)
For redialing user you can use call files or Asterisk Manager function originate. Call file can be used to call in future if you change creation time of file to future.
Simple flow can look like this:
User dial simple dialplan, run there some AGI, which read callerid and saves call file in near future. You do this without answering the call.
Call file dials user.
After answer you go to another dialplan which reads dtmf from user and dial that number.

CQRS - can EventListener invoke Command?

I want to use elements of CQRS pattern in my project. I wonder if i do it right with Command and Events.
The thing that I'm not sure is if event can invoke command. To better show what i want to do I will use diagram and example.
This is an example:
User invoke TripCreateCommand. TripCreateCommandHandler do his job and after success publish TripCreatedEvent.
Now we have two listener to TripCreatedEvent (the order of listener execution does not matter)
First listener (can be execute after the second listener):
for each user in trip.author.friends invoke two Command (the order of commands is important)
PublishTripOnUserWallCommand
SendNewTripEmailNotificationCommand
SendNewTripPlatformNotification
Second listener (can be execute before the first listener):
PublishTripOnUserSocials
And this is sample diagram:
Is this a good way ? Can EventListener invoke Command, or maybe I should do it in some other way ?
Your question is about Mesage Driven Architecture which works together with but otherwise unrelated to CQRS.
Anyway, your diagram is almost correct. The event subscriber/handler (I prefer this terminology) can send new Commands via the service bus, but it's not a rule that you should always do this. I implement quite a lot of functionality directly in the event handler, although probalby would be more clean and reliable to send a new command. It really depends on what I want to do.
Note that the message handlers (commands or events) should not know about other handlers. They should know about the bus and the bus takes care of handling. This means that in your app, the event handlers would take the bus as dependency, create the command and send it via the bus. The event handler itself doesn't know what command handler generated the event and can 'reply' to it.
Usually the commands would be handled independently and you can't guarantee the order (unless they're handled synchronously) so maybe you want the second command to be issued as a result of the first command's handling. Indeed, it can be the case for a Saga.
AFAIK you are talking only about doing things synchronously, so your approach works in this case but it's probably not scalable. Moving to async handling will break this execution flow. However your application can be fine with it, not everyhting needs to be twitter.
A message driven architecture is not that straightforward and for some cases (like you want an immediate response from the backend) it's quite complicated to implement, at least more complicated than with the 'standard' approach. So maybe for those particular cases you might want to do it the 'old' way.
If you're worried about decoupling and testing, you can still design the services as they were message handlers but use them directly, instead of a service bus.
Not sure why you would need Commands for performing the updating the information on the user's wall. Why would you choose not to use a View Model Updater for that task.
Sending an email can be considered a Command but could also easily be viewed as just another View Model update.
Not clear on what the purpose of the SendNewTripPlatformNotification is, so I cannot give any suggestions there...
Some of this could also be a candidate for a Saga. Secondly I'm missing your Domain in the diagram, that is what should be responsible for publishing any events, or do you consider the CommandHandler to be the Domain?

Asterisk callback with IVR survey

I´m pretty now to all this Asterisk-thingy and I wonder, is there a way how to call a user back from asterisk after he ended (hangup) call and give him a IVR survey, then save results somewhere (in form of audio records or DTMF inputs) ?
Sure there are alot of way to do that. But all require understanding of how asterisk works.
Hangup events can be detected by "h" extensions something like this
exten => h,1,System(/etc/asterisk/create_callback.sh)
After that you have create script for callback, see
http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out
You need create IVR in your dialplan
http://www.voip-info.org/wiki/view/Asterisk+Dialplan+Introduction
If you have programming experience you can use AMI(Asterisk Manager Interface) to generate your calls from Asterisk to your customers, based on whatever logic. Once the customer answer the call all you have to do is redirect it to your IVR context.
For the IVR(survey) portion, you may want use AGI(Asterisk Gateway Interface). You can access both APIs with virtually any programming language. Take a look of the following:
Adhearsion (Ruby)
Asterisk-Java or Astive Toolkit (Java)
PHPAGI (PHP)
Good luck.