I'm using Twilio to create phone calls between two phone numbers. In certain cases during the call I want to interrupt the call and play IVR messages. When I interrupt the call I want to play a different message to each person.
I see the way to interrupt the call is by redirecting the call here.
Then if I want to say some thing I use the twiml say command here.
But I can't see any way specifying which recipient receives what from the twiml. It seems that when you say a message it will be played to both people on the call.
Can Twilio support this functionality?
Twilio evangelist here.
So I think what you are going to have to do in this case is leverage a Conference. This may change how your initiating the two legs of the call. If you are currently using <Dial> to connect the two callers together, the problem there is that there is no easy way to get the Call SID of the second leg of the call. This means there is no easy way to redirect that call.
So instead of using <Dial>, what I normally do is when Caller A dials in, I put them into a conference, saving the name of the conference room to a database. Then I use the Twilio REST API to make an outbound call to Caller B. When they answer I put them into the same conference room as Caller A.
This also means I have both calls Call SIS, which I can use to redirect the two call legs independently. So in your case, when you wanted to Say something to Caller A, you would simply redirect them our of the conference, use <Say> or <Play> to talk to them, then redirect them back into the conference. Same process for caller B.
Hope that helps.
Related
ETA: I fully understand that it is Twilio's choice to charge however they want - my main intent behind asking was to avoid unnecessary charges on my end is there was any alternative. If not then that's totally fine too!
I have a system set up where if a caller dials my Twilio number, then I immediately forward it to another (standard) number using the <Dial> verb.
It is important to note that immediately after forwarding the call I do not care about handling the call any further on the Twilio side. In other words, I do not have an action attribute set on the <Dial>, nor any other instructions for Twilio on the forwarded call.
My question is then, why am I still charged per minute on the forwarded call? AFAIK Twilio has finished all of its work the moment the call is forwarded, and so I do not understand what it could possibly be charging per minute for. In my mind I should only be charged $0.0085 USD for the incoming call and nothing else.
Is there some other attribute I can add to the <Dial> verb which tells Twilio to end its work as soon as the call is forwarded and stop charging? Or is there a different verb altogether that I should be using?
You're looking for what is called "take back and transfer". Pretty much a star code (*44) that tells the telco that called you to take the call back and transfer it somewhere. So, first of all I don't know of any residential service that provides this service, this is generally enterprise telco service. Second of all, that's how Twilio makes its money so you're stuck paying for the inbound leg and outbound leg. I don't know anyone who does it differently.
I am using Twilio Client in my application, and I was wondering if there's a way to redirect a call mid-call on key press.
To be more accurate, is there a way to set up a listener for a specific key and Gather on keypress? I saw that Twilio recommends using hang up on star for these kind of things, but this option only listens to the caller's key presses, and I want to have the ability to redirect even if the call is inbound.
So I found a nice solution.
Instead of making a call using a one dial from a client/number to a client/number, what I did is create a conference call even if there are only 2 people speaking. This way both of the sides use the Dial verb and I can use hangUpOnStar on both the caller and the recipient.
I'm building an app where I have Twilio make a call, 'gather' the response from the callee and keep calling my backend because of the <Gather>.
However, I also want to be on the call live to hear what's happening in realtime. I was wondering if I can do this by using the Dial verb in conjunction.
This is what my flow looks like:
Twilio calls my server to get TwiML for a call it just made
Server returns a <Gather> response
Twilio calls server again with the data it 'gathered'
Server returns another <Gather> in response
...and so on.
This is what I'm trying to do:
(NEW:) I use webhooks to dial into a conference call 'C1'
Twilio calls server to get TwiML for a call it just made
Server returns a <Dial> followed by the gather response as earlier. I wanted the <Dial> to put the active call in the same conference C1 that I've already joined from another phone so I can listen to what's happening on the call.
Twilio calls server again with the data it 'gathered'
Server returns another <Gather> in response
...and so on.
So, what I'm trying to do here is to be on the conference before any of this happens so I can listen to Twilio interact with callee.
But looks if I try to append <Gather> to a <Dial> in a TwiML response, Twilio doesn't start 'gathering' from the conference call, but instead, waits for the conference call to finish first and only then execute the 'gather'.
PS: The closest approximation to what I want to do is set the record flag on beforehand when Twilio makes the call to the callee, and then listen to the entire conversation later to figure what happened but that's incredibly inefficient.
How can I help myself?
This is what my code looks like:
Gather g = new Gather.Builder().input("speech")
.action(BASE_URL + "/processSpeech?")
.timeout(4)
.build();
Conference.Builder conferenceBuilder = new Conference
.Builder("confie")
.startConferenceOnEnter(true)
.endConferenceOnExit(true)
.waitUrl("");
tmlb.dial(new Dial.Builder().conference(conferenceBuilder.build()).build());
VoiceResponse.Builder tmlb = new VoiceResponse.Builder();
TwiML tml = tmlb.gather(g).build();
Twilio developer evangelist here.
You can't use <Gather> within the context of a <Conference> so this flow is not possible. I'd suggest that you record the call and listen back to find out what happened. Though you say that is less efficient.
I'd like to help further, but I'm not sure what the exact use case here is. Perhaps you could share a bit more of what you are trying to achieve and I can update this answer?
How do I move the two parties involved on the call to a conference room at the same time?
I started the call through the Web SDK, thus the call started from a <Dial> element.
Now I have the ParentCallSid and ChildCallSid to identify each party.
But using the Twilio's PHP library, I can't seem to find how I can move both parties to a new URL (which would start the conference) at the same time.
And if I try to move only one at a time, the moment I move one party Twilio hangs up the other party, probably because it was left alone on the call. And the party I moved is successfully transferred to the conference.
On Twilio's docs there's no example of doing it. I've tried passing an array, passing a string separated with spaces, chaining the calls() method, but no luck. Couldn't find the docs of that method as well.
Twilio evangelist here.
Think the best option would be to just put them in a <Conference> at the start of the call if you can. Doing that is pretty simple. You drop the incoming call in the the conference, then using the REST API, you initiate the outgoing call to the second party. When they answer you drop them into the same conference.
If that's not an option, what you'll need to do is use the REST API to redirect each call leg into the conference. Redirect lets you tell Twilio to go get a new set of TwiML to execute for a specific call SID. In your case you want that TwiML to be something like:
<Response>
<Dial>
<Conference>BrayansBestConferenceEvar</Conference>
</Dial>
</Response>
Check out Modifying Live Calls in our docs for more info.
Hope that helps.
I've recently been using their API and if you add a pause after your initial dial command to connect to a call, then when you issue a command to move the child call and the parent right after, the call will be active for the move to register in their system. I use a 2 second pause for this.
I have a scenario to make a call through twilio. When I call the twilio, it gives me multiple options to connect just like a conventional IVR. Then I select a specific contact to through my call, Twilio makes me connected to the selected contact successfully. When I fetch the call duration, it returns me the whole time span, from IVR start to call ending.
Is there any option to fetch the call duration of the call with selected person.
Please reply soon.
Twilio evangelist here.
Sure. It sounds like your probably using the <Dial> verb to dial a number number from your IVR. In that case you can use the action parameter of that verb.
The URL set in the action parameter will be requested when the person you <Dial>ed ends the call. In that request, Twilio includes a few extra parameters, including one called DialCallDuration:
http://www.twilio.com/docs/api/twiml/dial#attributes-action-parameters
Hope that helps.