Scenario:
Person A calls my server. My server returns Twiml with Dial plus extra, connecting them to my client C. Sometimes C's phone is busy, and the extra just tells A they couldn't be connected, try texting.
I want to have a failover, where the same thing happens when C is not busy, but if C is busy, A is put in a queue, as are subsequent callers. When C's call ends, I try to connect A to C.
Is there a way of doing this with simple Twiml verbs, like dial.queue, and Redirect? So far I've failed: I can enqueue A when C is busy, hearing hold music and all, but I've utterly failed to get A off the queue and in touch with C. I suspect I'll need to create calls using the API, but figured I'd ask to see if the Twiml way should be doable.
I am aware that I could just throw all callers into a queue, but for business reasons I want to preserve the "ring and connect" behavior when the client is immediately available.
Twilio developer evangelist here.
The bit here is getting A to start a new call once they are done with the call they are on. You could, for example, send an SMS message to A to tell them that someone is waiting in the queue. Then, when they call their Twilio number back return TwiML that <Dial>s into the <Queue>.
When using the <Queue> TwiML, the caller will be connected to the person waiting at the front of the queue.
Alternatively, if you don't trust A to call the queue back, you could keep trying to periodically make calls to A using the REST API and once the call connects return the same TwiML to <Dial> into the <Queue>. If the caller hangs up and the queue becomes empty before A answers the call, you can stop calling and perhaps send a message to inform A that someone called and they can choose to call them back.
Related
We have a use case where we need the device client, connected within the browser, to be able to trigger different Say verbs at any given time during the live call between the device client and the caller. Whatever is said needs to be heard for both client and caller and included in the recording.
I set up an API endpoint that takes the CallSid and updates twiml, however, the statement is only heard for the device client and the calls are immediately disconnected. From my understanding, this is intended due to how TwiML works, since there is no other command after Say, so it believes the call is complete.
return await client.calls(callId)
.update({ twiml: '<Response><Say>Ahoy there!</Say></Response>' });
I've considered using a Redirect which would put the caller into a new flow to hear the prompt, however, the device client then wouldn't hear it, and it wouldn't be part of the recording, so that will not work. Using a conference call, the statement is only played for the new call either before they join or after their call ends.
Is there any way to accomplish this?
Setup
Suppose you have a caller who is enqueued into a queue. Then, your app dials an agent, who upon answering the call is connected to the caller in queue. The two parties are now bridged, or connected.
By passing hangup_on_star: true to the Dial verb, the agent is able to end the call by pressing star.
Question
Is there an equivalent way to enable the caller to end the connected call by pressing star? I would like for both parties to have this ability.
Workaround
The only way I can imagine enabling the caller to end the call is to have them send an SMS with something like "end" or "hangup" to my Twilio phone number, and then I would have logic to update the call resource with status: completed.
First up, setting a call to status: completed will end the call, which the caller could do by simply hanging up their phone.
If you want them to be able to hang up and then carry on to something else in the call then you won't be able to do this with a direct bridge like a <Dial><Number>. Instead, it would be better to send the caller initially into a <Conference>.
That way you can nest the <Conference> in a <Dial hangupOnStar="true"> and let the caller also hangup with star. <Conference> also supports wait music if you set startConferenceOnEnter="false" for the caller.
Then, when you dial out to the agent, the TwiML you provide to them should direct them into the <Conference> with startConferenceOnEnter="true" so that when they connect they can immediately start talking to the caller.
Then, for either side of the conversation you can add further TwiML after the <Dial> and when they hang up with star they will go onto that TwiML.
I have a somewhat peculiar situation for which I can't find documentation: I have an application that will use the Twilio API to initiate a voice call from phone number X (my number) to another one. The problem is that number X could already be in the middle of another call, one that was not initiated with Twilio (so my application wouldn't know about it). Would Twilio detect this, and send an error, or try to initiate the call anyway? If the former, what would the error be? I have found the error code for "callee busy", but nothing similar to "caller busy".
Alternatively, is there an API call I could make before initiating the call to make sure number X is available and not in another call?
Twilio numbers can have multiple calls associated with them, so there would be no error id the Phone X was on an existing call (since phone numbers can be routed however you choose). You can set the outbound CallerID to be another Twilio number or a verified callerID (but if they call that verified callerID back, it wont go back to Twilio but the carrier/business owning that number).
Once the dialed party answers after making the outbound API call, you tell Twilio how to route the other piece (who to connect the answering party to) via the URL parameter hosting the Twilio Markup Language (TwiML).
There is an API call and example for, Read multiple Call resources and filter by call status and phone number (Code Example), you could query before making your outbound call (assuming you always map inbound calls to the same endpoint) or routing your inbound call (which probably makes more sense if you want to re-route to another destination who can answer the call).
The status of this call. Can be: queued, ringing, in-progress, canceled, completed, failed, busy or no-answer.
I'am using twilio to set up a call between 2 people
I'd like to manage call transfer asked from one side (like when a dtmf key is pressed). The other side could listen to a prompt who could be "please wait while your call is being transfered"
Any chance to do that properly with twilio?
When both parties are connected, Twilio blocks execution of further verbs until the caller or called party hangs up. That's why it is not possible in regular way.
But you can hangupOnStar attribute to hangup the caller party. And set an action URL to continue next dial verbs.
Here is a detail answer:
Twilio call transfer from in-call
I am trying to figure out a way to capture if the caller hangs up in the middle of TwiML instructions. If the caller hangs up (abandons the call) does twilio notify the application of such?
I see the status callback url setting but I just get a "completed" status. I was wondering if the caller was in a middle of a gather and hung up would twilio know the call hung up and report it? Or am I supposed to just see the "completed" status and at that time determine if the call actually successfully completed or not?
Twilio evangelist here.
To my knowledge we don't have a specific way of telling you that a caller hung up during the middle of a <Gather> other than the status callback passing you the CallStatus, which as you points out just tells you that the call was completed, not where within a TwiML document or a call flow the caller was.
If you want to know where within a call flow the call ends (for example the caller hangs up), I'm pretty sure that is something you would need to track in your own application. You could do that by storing the callSid of the phone call along with some meta data that helps your app know where in the flow the call is, and just updating each time Twilio makes a webhook request to your app.
Hope that helps.