Introducing Last In, First Out (LIFO) Support for TaskRouter

October 24, 2016
Written by
Al Cook
Twilion

TaskRouter

Today we’re excited to announce that TaskRouter now supports Last In, First Out (LIFO) for routing tasks. Before we get into LIFO, a quick refresher: TaskRouter is a skill-based routing engine, designed for routing work such as customer support interactions or sales leads to the best matched agent. The addition of LIFO means that you can now choose between the default behavior where the longest waiting task gets delivered to the next available worker, or a new option where the task that has been waiting the least amount of time will be routed to the next available worker.

So why LIFO? Certainly for a lot of call center use cases, the default (FIFO) behavior is what’s called for. However, we’ve seen a lot of folks use TaskRouter for all sorts of use cases beyond the typical inbound support contact center. One of those where LIFO is really important is in handling leads.

Let’s take an example where you are generating leads on your website and have agents call back those leads. A lead is hottest at the moment it’s created, and ‘cools down’ quickly, equating to an increasingly lower chance to convert that lead. So it is really important to connect the first free agent to the hottest (newest) lead in the system, since that has the highest likelihood of conversion. This is where LIFO helps you out.

LIFO is a TaskQueue level setting and you can enable it on a TaskQueue by passing TaskOrder=LIFO  while either creating a TaskQueue or updating an existing TaskQueue. The default is FIFO.

$ curl -XPOST https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/TaskQueues \
   -d "FriendlyName=HotHotLeads" \
   -d "ReservationActivitySid=WAxxxx" \
   -d "AssignmentActivitySid=WAyyyy" \
   -d "TargetWorkers=languages HAS 'english'" \
   -d "TaskOrder=LIFO" \
   -u '{account_sid}:{auth_token}'

In a FIFO Queue, if you have 5 tasks from F1 as the oldest to F5 as the newest, they will be routed as follows (Task furthest on the right is the next to be assigned to the agent):

Inbound Tasks -> F5, F4, F3, F2, F1 -> Agent

In a LIFO Queue, if you have 5 tasks from L1 as the oldest to L5 as the newest, they will be routed:

Inbound Tasks -> L1, L2, L3, L4, L5 -> Agent

Now let’s imagine your setup has Workers shared between LIFO and FIFO TaskQueues. We need to specify whether the most recent task from the LIFO queue or the oldest task from the FIFO queue is most important. In this case the preference by which they consume tasks from a FIFO Queue vs a LIFO Queue depends on a workspace level setting PrioritizeQueueOrder. Simply pass PrioritizeQueueOrder=LIFO  or PrioritizeQueueOrder=FIFO  while creating a new workspace or updating an existing workspace.

$ curl -XPOST https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ \
   -d "FriendlyName=MixedOrderedWorkspace" \
   -d "PrioritizeQueueOrder=LIFO" \
   -d "EventCallbackUrl=http://requestb.in/vh9reovh" \
   -u '{account_sid}:{auth_token}'

Let’s take a look at how the PrioritizeQueueOrder setting works if your Agent is able to take tasks from both TaskQueues. We’ll combine the two examples above, and set PrioritizeQueueOrder  to FIFO. In this case, the Tasks are routed in the following order:

Inbound Tasks -> L1, L2, L3, L4, L5, F5, F4, F3, F2, F1 -> Agent

Compared to if PrioritizeQueueOrder is set to to LIFO:

Inbound Tasks -> F5, F4, F3, F2, F1, L1, L2, L3, L4, L5 -> Agent

There are many possible use cases that can be satisfied using LIFO, or combining LIFO and FIFO Queues. If you find you need additional functionality on top of LIFO and FIFO, we want to hear from you. In the meantime, we can’t wait to see what you build.