1
votes

I'm setting up a lead-dialing solution using Twilio's TaskRouter functionality, and the client wants the most recent lead in the queue to be called first.

The documentation indicates that TaskQueues are FIFO, i.e. "Among tasks of the same priority, the oldest task will always be assigned first."

Is it at all possible to set TaskQueue behavior to LIFO?

1

1 Answers

1
votes

Twilio developer evangelist here.

I've not done something like this before, however it occurs to me that you could just use an incrementing counter to set the priority of the tasks as higher number priorities are seen to first. As an example, if you set the priority of the task to be the Time in seconds since the epoch then it will be an ever increasing integer always making newer tasks appear at the top of the queue.

Let me know if this helps at all.

[edit]

TaskRouter now supports LIFO queues so you no longer have to mess around with priorities in order to create the behaviour. Queue order is set on the TaskQueue object. When you create a TaskQueue you pass the TaskOrder parameter as LIFO. The default is FIFO. Here's an example with curl:

$ 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}'

For more information, check out the documentation on LIFO queues in TaskRouter and the introductory blog post.