Search code examples
twiliotwilio-programmable-voicetwilio-taskrouter

Find the voice task currently assigned to a specific worker


This sounds pretty straightforward, but I'm not sure it's something I can do. I want to know what voice task a specific worker is currently working on (if any) without having to store this information on my side when the task is assigned to that worker.

The reason why I'm looking for this because I'm using conferences to pick up incoming calls to agents and I want to implement whisper/barge/coach for supervisors. They'd know which agents are currently on a call (based on the agent's Busy activity) and based on the workerSid of the agent they want to coach, I want to be able to get the voice task they're currently working on and join that conference (since the TaskSid is also the conference friendly name).

I could loop through the current open tasks, trying to find the right one, but there doesn't seem to be anything on a task that is in an assigned status to indicate who it was assigned to. The only way I can see to do this using only information I can get from Twilio is a bit too messy:

Any other way would seem to involve looping through conferences that are currently in progress, then loop through their participants to find the call leg made to the contact_uri of the agent to coach to identify the right conference to join, which would be even messier in my opinion.

I'm wondering if there's something obvious that I'm missing.


Solution

  • Twilio developer evangelist here.

    The way that you've described seems to be the best way I can find to get this information from the API without storing anything yourself.

    If you don't want to store the data in your own server, then you could update a worker's attributes with the current voice task SID. You still have to maintain listening for the end of the call and removing the attribute though.