I want to implement a solution where, if there are no available workers Twilio I don't send it to Flex, but do something else (e.g: say a message to contact us by other channel type, run a Function, or any other option)
Best posible scenario: Inside a Studio Flow, before creating a Task and sending it to Flex, I want to check if in that queue there are any available worker.
Alternative: If that not posible, because to know the worker's availability depends on TaskRouter's Workflow, Is there any way to go back to Studio after a Timeout (i.e: an abandoned call)?
The only available option I found (but did not implemented yet) is setting a callback in the TaskRouter > Settings and handle de Workflow Timeout event. But in this case I lose all the context I had in the Studio Flow (e.g: the options the user selected in the IVR).
Flex TSE here.
Both options are possible.
For the first, you can use a Run Function widget in your Studio flow to run something like:
to retrieve the available agent count. From there, you can route accordingly based on the return value.
If you want to route a task back to the IVR, you can create a Flex Plugin that uses the TwiML redirect verb to point to the Webhook for the studio flow.
For example:
Additionally, you can get full sample code for an agent-driven redirect from this blog post.