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.
Related
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?
Why twilio not provide a hold option as like their mute option?
It doesn't make sense, to use a API to do this option because it just like the mute option except it needs Hold music to be played during for caller.
Any solution? or update?
as for a solution, I would understand that an agent is only dealing with a single call at any one time, so having to place a caller on hold, should be pretty simply, you could simply take the call and place it into a conference where you can play the music of your choice. You could use the agent name perhaps and add hold to it to easily get the agent back to the call in the conference, so perhaps creating a conference in such a way, where the agent name is agent1, the conference name could be agent1hold. Once the agent has finished with that which he was busy with when placing the call on hold in the first place, he could simply dial back into the conference. you would need to make sure that you setup the conference correctly so that if the caller has to be placed on hold again, and the agent exits the conference, that the conference is not terminated.
Megan from Twilio here.
Basic hold functionality can be handled via modifying live calls:
https://www.twilio.com/docs/api/rest/change-call-state
An example in Python where you would use the URL parameter directing the caller to some TwiML to <Play> the caller some hold music. You easily give this a try by hosting the TwiML with Twimlbin.
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "AUTH_TOKEN"
client = TwilioRestClient(account_sid, auth_token)
call = client.calls.update("CALL_SID", url="YOUR_TWIMLBIN_URL",
method="POST")
And some examples of working with other scenarios involving <Conference> can be found on our blog.
In Java: https://www.twilio.com/blog/2015/08/how-to-warm-transfer-a-call-with-java-and-twilio-voice.html
In Python: https://www.twilio.com/blog/2015/09/warm-phone-call-transfers-with-python-flask-and-twilio-voice.html
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.
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.