I am new in Twilio and i have been facing an issue while designing outbound dialer currently preview dialing. If a worker rejects a task than the same task should not be offered to that worker again.
How do i handle this case?
Typically if a worker rejects the task, the worker should be moved to an unavailable activity. Otherwise, if the worker is the only available and qualified worker, TaskRouter will continue to create new reservations.
You can specify a new activitySid upon rejection, so that the worker is moved to an unavailable activity at the same time:
https://www.twilio.com/docs/api/taskrouter/worker-js#reservation-reject
Here, making the worker activity unavailable would simply mean the worker will not be able to get any task.
But let's look at a more complicated use case where a Worker can accept, reject or cancel tasks. They need to be available to make this choice.
If you have only that agent, and they are available, then there is no way to prevent that agent from receiving the Task, unless you manipulate the Task attributes or worker attributes so that TaskRouter doesn’t assign the Task. For example, you could update TaskAttributes to have a rejected worker SID list, and then in the workflow say that worker.sid NOT IN task.rejectedWorkerSids.
And the ability to do this Target Workers Expression just shipped as a bug fix today! It should look like:
worker.sid NOT IN task.rejectedWorkers
Related
In our Twilio application we would like to use TaskRouter to distribute incoming calls. Suppose we would like to handle the following scenario:
All Workers login to front-end application and have their status set to Available. If there are any incoming calls, Workers receive them in the UI.
Some Workers have this custom attribute: {"work_hours": [600, 1600], "phone_numbers": ["+1...", "+1..."]}. If for some reason this Worker becomes Unavailable during their working hours set between "work_hours" attribute, we would still like to have incoming calls forwarded to their personal phones from "phone_numbers" attribute.
If the above fails, we would like to forward the incoming call to Voicemail.
Basically, my question is whether it is possible to include Unavailable workers to Workflows and Task Queues? The above scenario would most likely require 3 Task Queues: one for all Available Workers, one for Unavailable but with "work_hours" attributes where taskrouter.currentTime is between those hours and one for Voicemail.
Twilio Solutions Architect here!
I think that you may already found a solution for your problem, but in case someone else is having this problem, here's my solution:
The best way to do this is actually creating a new Activity on TaskRouter of type Unavailable with Work Hours that is is an available Activity. With that state created, you can set the worker availability to this state when they are on this use case, and with the Task Router Workflows, you can have specific queues for these agents and using the routing strategies, bring a task to this queue if necessary.
Regarding to call the agents on their personal phone numbers, you can create a conference between the original call and the agent's phone number and have them connected.
This is a bit tricky, but is completely possible.
There is one task Assigned to WORKER A, however after spending sometime, WORKER A realized, this can not be handled by own and needs to be transferred to WORKER B.
How can we achieve this using Twilio Task Router?
First you have to understand how is the lifecycle of a Task.
When the task is created. the first state is pending.
Then, Twilio will look for a worker who has capacity to get this Task.
The task is now reserved.
When a Task is reserved, this task could not be assigned to a new agent, because it violates the Task LifeCycle. (https://www.twilio.com/docs/taskrouter/lifecycle-task-state)
If you are going to solve this problem, you have two options:
If you want a Flex solution for the twilio flex plattaform you can use a plugin available (https://www.twilio.com/docs/flex/solutions-library/chat-and-sms-transfers)
If you want to solve it with a backend solution. you have to first:
delete or complete the Task.
Create a new one with the same Task attributes to preserve the data in the
conversation.
Create a new channel to communicate the worker with the task user.
Assign the task to the workerSid (WorkerB). Remember that, you have to handle if the worker B has no capacity to recieve a new Task
I have a task router with some workers, when there is an incoming call and the worker does not answer the call, then the worker is been updated, and the status is been set to offline. Can I avoid that and keep the worker in the available activity state?
worker.on 'activity.update', #_onWorkerActivityUpdated
Configuring Default Activities for Worker State Transitions
If a Reservation times out, the Worker is placed in the TimeoutActivity identified by the Workspace. By default this is Offline.
I'm currently using task router to route calls to my workers and I want to temporarily prevent certain workers from getting assigned voice tasks. I thought by updating the worker channel capacity for voice to 0 or marking the voice worker channel as unavailable would mean that while the worker remains a part of the queues (based on their custom attributes), if there are any voice tasks coming in, they would not be assigned to that worker. That does not seem to be the case, my worker still receives reservations for voice tasks.
I tried to update my queue to only include workers that have voice capacity by adding this check to the Queue expression '... AND worker.channel.voice.configured_capacity > 0', however when saving the queue in the Console, I get an error saying 'Worker channel capacity expressions not allowed in TargetWorkersExpression on TaskQueue' which leads me to believe that this is not the right thing to do.
The only other solution I can see is to add the worker channel capacity check mentioned above to the target expression at every step of my workflow but that would be harder to maintain.
I can't help but feel that there's something I've missed or misunderstood about how the worker channel capacity works or what it is used for. For what is worth, multitasking is disabled for my workspace.
Twilio developer evangelist here.
Adjusting the capacity when you are not using multitasking won't make a difference.
I would recommend using a custom attribute on the worker and then filtering based on that within the target workers expression instead.
We are using Twilio Task Router with Multitasking disabled Workspace and only default Task Channel set as Available for all Workers. After the Task Reservation is Accepted the Worker activity goes from Reserved to Busy, as expected. But finally when the Task status is updated to 'Completed', the Worker activity is not getting changed to Idle as expected, but instead it stays in Busy activity. Is this a bug or the expected behavior? Or are we missing any configuration?
Twilio engineer on the TaskRouter team here! Yes, this is expected behavior for single-tasking.
What you'll find is that when the Reservation is assigned, the Worker it's assigned to will move to the the "Busy" Activity for that TaskQueue (or whatever Activity is specified for assignment, which can be change via the API here, or you can set it via the Console here), as you've described.
When a Task completes, however, there is no guarantee in a single-tasking environment that the Worker is actually ready to take work again at that moment—they may be, but that depends on your workflow. So we need confirmation before assigning Tasks to them again. This is why the Worker's Activity needs to be manually set back to "Idle" before they will start receiving Tasks again.
One of the easiest ways to do this, if this is the workflow you want, is to listen for the task.completed event, either at your EventCallbackUrl or via the JS SDK, and issue an Activity update to "Idle" for the associated Worker at that time.
Hope this answers your question!