Transfer call from Twilio auto pilot to Taskrouter? - twilio

I am creating Autopilot which greets the user when a Twilio number is called.
Then Autopilot will ask the user if he wants to connect with the agent according to the answer of the user. If user say yes then Autopilot will transfer the call to task router. By seeing Twilio example i Have reached to handoff the call to task router.
The problem is that I cannot specify Matching Task. In a Taskrouter workflow, I have 2 to 3 filter I want to pass matching task so that A particular filter is run of the workflow
Currently, I am using the below command For handoff.
"handoff": {
"channel": "voice",
"uri": "taskrouter://workflowid",
}
Here I need to able to pass matching task (An addition parameter) something like selected_agent === 'lorem' which will tell the workflow which Particular task(Filter) to run

From the documentation (the Dialogue Payload is a task attribute):
When handing off an Autopilot voice session to Task Router or Flex,
you need to provide the destination the Task Router workflow Sid. When
the Hand-off is executed the Autopilot session is terminated, the call
is enqueued with the Dialogue Payload as a task attribute.

Related

Twilio TaskRouter Serverless Reservation Function

Has anyone completed or found a guide on routing/ accepting a task router reservation?
Example flow:
Call # > picked up by Twilio Studio and enqueued to TaskRouter Workspace with attributes > task router workflow associates to a taskrouter queue and finds available agent > [i need to connect this call to the workers attribute which is their sip:phonenumber
I'm trying to avoid an aws server and lambda while keeping this entire orchestration native to twilio via function.
Twilio developer evangelist here.
The docs on dealing with the TaskRouter reservation callback are here. When you receive the callback you need to respond with JSON describing the action you want to do.
The simplest instruction to connect the call from task to the worker that receives the reservation is to use the dequeue instruction. In a Twilio Function that would look like this:
exports.handler = function (context, event, callback) {
callback(null, {
instruction: "dequeue"
});
}
To make this connect, your worker needs a contact_uri attribute that points to their address, in this case their SIP phone number. Alternatively, you can add a to attribute to the dequeue instruction with the address.

Twilio Flex. Start a stream once an agent has accepted a task

so, the flow is, I call enqueue Twiml verb. It creates a task and assigning to a specific agent. I have a task router callback on reservation.accepted event. I got it, but once I update a customer call with Stream Twiml - it's removing a customer from the conference which Flex creates. I'd like to avoid it somehow. To avoid that I update a customer participant with end_conference_on_exit: false attribute. Then I update a customer call with Stream and Dial.conference to get a customer back to a conference which I do not like. Is there any easier way to implement it ?
Twilio developer evangelist here.
Updating a call like that will always take it out of it's current TwiML flow and you would have to redirect back to where it was, like you have already implemented.
I know this is not starting the stream after the task is accepted, but I think the best way to implement this right now is to use the fork stream Studio widget directly before the send to Flex widget in the Studio Voice IVR flow.

Autopliot with Whatsapp and route the conversation to Agent in Flex

Is there any way to forward the conversation which started with the AutoPilot to a real agent in Flex? For example, somehow, a customer may want to talk to or text with a "Real" agent when they find that the AI bot cannot answer their question. Is that possible to achieve this?
Twilio developer evangelist here.
The best way to achieve this is to follow this guide on setting up Handoff from Autopilot to human agents.
Briefly, you need to set up an Autopilot task called something like "talk-to-agent". That task should not include a "listen" directive, so that when the task is complete the Autopilot session is over.
Then, you direct incoming messages through a Studio Flow and into the Autopilot bot. When the session ends, you can then check the CurrentTask attribute of the Autopilot widget using a Split widget. If the task is equal to "talk-to-agent" you can direct the flow into Flex with the Send to Flex widget.

Twilio en queued calls not coming through to agent phone

I am using Twilio Studio to configure an IVR system and was successfully able to do that. Now I am trying to create a queue with few agents so that the calls are not missed. I was able to create a Task Router and create a queue under that, as follows.
I have added two agents to the queue as follows
Now when I make a call, I can hear the music, but the calls are not coming through to the phone. Not sure what I have to do now
Twilio developer evangelist here.
The task workflow goes something a little like this:
Call comes into queue -> Task created -> Task is pending -> Workflow finds Worker -> Reservation created -> Reservation accepted -> Call is routed to worker
From what I can tell, you've done everything but accept the reservation for your worker.
To do that you need to set the Assignment Callback URL for your Workflow. Then, when the reservation is created for a worker Twilio will send a webhook (HTTP request) to that URL. Your application can then accept the reservation and dequeue it immediately, or do a bunch of other things. I recommend you read through the documentation on Task Lifecycle: workflows and assignment for an overview followed by how to Handle Assignment Callbacks for how to put that into action and produce your assignment callback handler.
The simplest thing you can respond with is the dequeue instruction which will connect the call to your worker's contact_uri. That would look like this:
{ "instruction": "dequeue" }
Let me know if this helps at all.

Twilio Queue management issue / best practice

We are setting up a call center using Twilio.
At the end of the greetings and menus, our users are redirected to a queue waiting for the next available agent.
We would like the system to:
- Call automatically the next available agent. This is to prevent the agent from dialing the queue to know if users are waiting.
- Be able to change the order of the queue. Our users have different priorities.
How can we get this done? What are the best practices?
FYI: We are using PHP, TWIML and we DO NOT have our own IPBX (Not able to use SIP Protocol).
Thanks,
Dimitri
Twilio evangelist here.
There are a few ways you could do this, but my suggestion would be to use the action attribute of the Enqueue verb.
The action attribute lets you tell Twilio about a URL that you want it to request when a caller leaves the Queue. As part of this request, Twilio will pass you a parameter named QueueSid. Using the QueueSid, you can make a request to Queues endpoint in the Twilio API, see if the current_size of the Queue is greater than zero, and if it is initiate a call out to the next available agent.
Hope that helps.

Resources