javascriptpythondjangotwiliotwilio-taskrouter

How to get Twilio worker for incoming calls using TaskRouter? - Django


I'm building a simple Django contact center app using Twilio, TaskRouter, Client JS SDK.

I'm using the status_callback to save the calls log for each customer in db by listening to the request with complete status_callback_event. (not sure this is the best way but it does the job)

How would you go about saving the worker who received the incoming call?

For outgoing calls I'm passing the request.user in the url as a custom parameter and I'm getting it in the status_callback.

For incoming calls I'm getting the ParentCallSid in the status_callback, I assume I can use it to fetch the client who handled the call through the Rest API.

Am I doing the right thing here? is there a simpler way to get this done?


Solution

  • I used in the end TaskRouterEvents to listen to reservations events (reservation.completed or reservation.canceled) I took the WorkerSid from the POST request and saved it in db.
    I think this is the easiest way to go about doing this.
    For outgoing calls I'm passing the WorkerSid in the url as a custom parameter and I'm getting it in the status_callback.