Overview
This article explains how to configure alerts in Twilio Flex (using TaskRouter) to notify you when a task is in a queue but no workers are available to handle it. This is a common requirement for contact centers that want to ensure no customer requests go unattended, especially when managing a large number of queues.
You want to be alerted when:
- A task is placed in a queue (e.g., an incoming call or chat)
- There are no available workers to handle the task (all are offline, busy, or otherwise unavailable)
Environment
legacy Twilio Console
What You Need To Know
Twilio Flex does not provide an out-of-the-box alert specifically for this scenario. However, you can achieve this using TaskRouter’s event callbacks and custom alerting logic.
1. Use TaskRouter Event Callbacks
TaskRouter emits events for all task and worker activities. The most relevant events for this use case are:
-
task.created: Triggers when a new task is created. -
workflow.timeout: Triggers when a task reaches the end of a workflow without being accepted and is removed from the workspace
How to set up:
- Configure a webhook endpoint to receive TaskRouter event callbacks.
TaskRouter Event Reference - In your webhook handler, listen for
task.createdandworkflow.timeoutevents. - When a
workflow.timeoutevent occurs, check if the task is canceled due to workflow timeout.
2. Implement Custom Alerting Logic
Once your webhook receives the relevant event:
- Trigger an alert (e.g., send an email, SMS, or push notification) to supervisors or monitoring systems.
- Optionally, log these events for reporting and analytics.
Example Workflow:
- Task is created and enters a queue.
- TaskRouter attempts to assign the task.
- If no workers are available, a
workflow.timeoutevent is sent to your webhook. - Your webhook logic sends an alert to the appropriate team.
3. Monitoring at Scale
If you have many queues (e.g., 200+), ensure your webhook logic can handle events from all queues and aggregate alerts as needed to avoid alert fatigue.
Frequently Asked Questions
Can I set up this alert directly in the Twilio Console?
No, this specific alert requires custom logic using TaskRouter event callbacks.
What if I want to alert only for certain queues?
Filter the events in your webhook logic based on the queue SID or name.
Are there any pre-built plugins for this?
As of now, this requires custom development, but you can leverage Flex Plugins to enhance notification capabilities in the Flex UI.
Conclusion
While Twilio Flex does not offer a built-in alert for tasks queued with no available workers, you can implement this functionality using TaskRouter event callbacks and custom alerting logic. This approach provides flexibility and can be tailored to your organization’s needs, regardless of the number of queues you manage.
Below you will find references to useful documents:
- TaskRouter: How It Works
-
Flex Alerts for Contact Center Metrics
(Note: These built-in alerts do not specifically cover the “no available workers” scenario, but can be useful for monitoring queue metrics.) - Working with Notifications in Flex
If you need assistance implementing this solution or have questions about your specific setup, please consult the Twilio documentation or reach out to your Twilio representative.