I have a workflow in Twilio which have multiple queues. I need to calculate average wait time for each incoming user based on their position in that specific queue and announce it back to the user.
1 Answer
Twilio developer evangelist here.
You can grab the information about current and historical queue stats from the workflow statistics api: and generate custom TwiML from that you can then use as the waitUrl on the Enqueue verb.
Note that from the <Enqueue> Docs, some statistics are passed by default to the waitUrl so depending on exactly what you need you may not need to call the statistics API.
avgTaskAcceptanceTime looks like it is of interest to you--it's "The average time (in seconds) from Task creation to reservation acceptance while in this TaskQueue." Or the WaitDurationUntilAccepted ("The wait duration stats (avg, min, max, total) for tasks that were accepted while in this TaskQueue")
Let me know if this helps at all!