Search code examples
twiliotwilio-taskrouter

Twilio Task Router - How to transfer assigned Task to some other worker?


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?


Solution

  • First you have to understand how is the lifecycle of a Task.

    1. When the task is created. the first state is pending.
    2. Then, Twilio will look for a worker who has capacity to get this Task.
    3. 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:

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

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