twiliotwilio-click-to-calltwilio-flex

How to get outbound call sid that is created with StartOutboundCall from Flex


I'm making outbound calls through Twilio Flex with StartOutboundCall built-in action. I want to be able to manage call recording during and after the call so that I can start-stop-delete recording when necessary. However, I am not able to get call sid to do so. Is there an easy way to get call sid for a call that is started by StartOutboundCall?


Solution

  • After playing around with Flex events and some support from Twilio, I found an object conference is being added as a task attribute after the event afterAcceptTask.

    The conference object contains both agent's and customer's call sid. You can use the agent's call sid, which is under task.attributes.conference.participants.worker, to manage the call recording or other resources that require a call sid.

    Note: I wasn't able to get this conference object consistently in the afterAcceptTask listener, so I made sure that I accessed the object after this event. This way I consistently hit the object and was able to get and use the call sid successfully.