Menu

Lifecycle of a Task: Timeout Evaluation

Timeouts help create a good customer experience by ensuring that a Task never gets "stuck" in a Queue with no available workers. Timeout behaviors can be tricky to master, but once you do, they'll give you fine-grained control over the movement of your Tasks through your Workflows.

Consider the following Workflow:

The Code

{
    "task_routing": {
        "filters": [
            {
                "targets": [
                    {
                        "queue": "Q1",
                        "timeout": 10
                    },
                    {
                        "queue": "Q2",
                        "timeout": 10
                    },
                    {
                        "queue": "Q3",
                        "timeout": 10
                    },
                ],
                "expression": "1==1"
            }
        ]
    }
}

The reservation timeout is 5 seconds.

For the sake of simpler visualization and reasoning, we've artificially increased the time it takes to create a Reservation - your Workflows will likely run much faster than the one described here!

What Happens

An animated rendering of Task Evaluation

  1. Task A is created against the Workflow.
  2. At t=3, a Reservation created for Task A against Q1.
  3. At t=8, the reservation times out for Task A.
  4. Task A re-evaluates and maps to Q2.

The Queue timeout is now the sum of Q1 and Q2 timeouts: 20. The target timeout for this task will happen in 12 sec, however, because it is based on the Task's current time. Unlike the Reservation Timeout (which always starts at zero), the queue timeout will be based on the current age of the Task.

Next Steps

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting our Twilio Community forums or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more