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?
Related
I'm using the Twilio C# SDK to initiate an outbound call from Twilio, during which user's DTMF input needs to be gathered (Press 1 to be transferred to sales, 2 for support...), and the subsequent action is to forward the call to a designated E164 number that matches the key.
So the VoiceResponse.Gather() method takes this action parameter that is a webhook Uri to which the user input will be posted and we can surely forward the call from there.
var twiml = new VoiceResponse();
twiml.Say("...");
twiml.Gather(numDigits: 1, action: webhookUri);
But is there a way to achieve this simple forward instruction within the current twiml object without involving an external webhook? Basically something that gathers the user input digit, correlates to a E164 number(using a predefined dictionary), then Dial directly.
Twilio developer evangelist here.
No, there is not a way to achieve the instruction after the <Gather> without another webhook. You must pass a URL as the action parameter and respond to the webhook with the next set of TwiML to direct the call onward.
If you do not want to host the application that responds to this webhook yourself, you could achieve this flow using Twilio Studio, which is a drag and drop editor for communications flows, or using Twilio Functions, which is a serverless environment where you can respond to incoming HTTP requests with JavaScript functions.
I have an incoming call that triggers an outgoing call. When the outgoing call is answered, I want to SAY an announcement, ideally without the original caller hearing it.
I tried to respond with a TwiML to the callStatusCallback and I also tried nesting the SAY node within NUMBER. Both didn't work. Any ideas?
Twilio developer evangelist here.
What you're referring to here is commonly known as a call whisper.
You can implement it by providing a URL to the <Number> verb in the TwiML you return that forwards the call. That URL should return some more TwiML, in this case <Say> with the text you want to read out. Then when the call is forwarded, Twilio will make a webhook to that URL when the user answers and only connect the calls when the TwiML is complete.
Let me know if that helps at all.
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'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.