twiliotwilio-apitwilio-twimlconference

On Twilio Voice Conference how to call several agents and hangup after first one answered


All is using cell phone, no soft phones.
I am trying to created a flow where a customer calls in, All the agents that are available will have their phone ringing. The first agent that answers, all other dials are disconnected. Later, during the call, the agent will need to add one or more other agent to participate in the call.
As far as I can see the response to the customer call should be a Twiml on the lines:

<Dial><Conference>My Conf</Conference></Dial>

But what should I add to this so it calls (for example) three more agents, and hangup on the other agents after the first one answers? Something like this (this does not work):

<Response>
    <Dial><Conference>My Conf</Conference></Dial>
    <Dial callerId="+1888XXXXXXX">
        <Number>111-987-6543</Number>
        <Number>222-987-6543</Number>
        <Number>333-987-6543</Number>
    </Dial>
</Response>

Solution

  • The approach above won't work well in production. When an agent is on a call, future calls will still be sent to all agents and that Agent on the call's voice mail will pick up.

    Look at Twilio Task Router for a way to properly assign calls to agents. Task Router has an SDK which you can use to allow agents to go online. Agents are assigned to Task Queues which allow proper routing. If an agent is on a call, Task Router will not attempt to assign them another call.

    You can also handle conference events with Task Router.