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.
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.
When a customer dials my Twilio number, I need Twilio to first try to call my PBX system. Currently using 3CX. If the call is not answered by a person, I need to find a way to send that call back to Twilio and go to another resource. For my purposes, that resource is Twilio AutoPilot.
Basically, if a human doesn't answer the phone, I want the robot to try and help the customer instead.
The only thing I've been able to come up with so far is to create another Twilio number and have that number be the fallback within the PBX. The problem with that solution is with Twilio, you cannot mask the number to match the CallerID of the customer calling in, and I would really like to be able to know that number. Also you are creating 2 call paths, which could make this an expensive option.
The only other solution I could think of, which would use 3 calls paths, would be to use another provider that does allow me to mask the caller id, and then send that to the Twilio number.
I am not a programmer, I have basic coding knowledge, but just barely.
Any help would be appriciated. Thanks
You can use Programmable Voice with a SIP Dial to initially contact your PBX (it will appear the same way an Elastic SIP Trunk call will appear to your PBX). The easiest way is to use the Connect Call to Widget in Studio. If that call fails, say 3CX returns a 404 - Not Found, Studio can continue to the next Widget via the Connected Call Ended path which can then perform additional steps of your choosing. The CallerID is maintained this way as well.
Elastic SIP Trunking is not designed for this particular call flow but rather a simple conduit from/to the PSTN.
Happy Path
Fallback Path
I was looking into attributes of Dial verb. In Dial verb, we have an attribute hangupOnStar. So if we created a call using dial verb and set attribute hangupOnStar then in the middle of the call the user can hang up the call by pressing star (*) on his phone. And then next verb will get executed in the twiml response.
So my question is can we create our own custom attribute like toHangupPress (some_key)? I searched the web but didn't find any documentation in this regard.
Can we create custom attribute at any place in Programmable Voice of Twilio?
Twilio developer evangelist here.
You cannot create custom properties for TwiML, so it is not possible to hang up with any other keypress when using <Dial>.
If you are doing other things, then you can use <Gather> to take keypresses and react to them, however it's not possible to nest a <Dial> within a <Gather>.
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.