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.
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.
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.