Reputation: 902
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
?
StartOutboundCall
some info: https://www.twilio.com/docs/flex/developer/voice/dialpad-click-to-dial#the-outbound-call-action-1Upvotes: 1
Views: 852
Reputation: 71
After dealing with a similar issue, Twilio support instructed me to use the worker as CallerSid, which works perfectly.
The trick is to use this event because it is the moment the call have being created/connected/accepted, and the worker is available as CallerSid.
Twilio.Flex.Manager.getInstance()
.workerClient.on('reservationCreated',
(reservation) => {
reservation.on('accepted', (accepted) => {
console.log("!!!!Reservation", accepted.task.attributes.conference.participants.worker);
});
});
afterTaskAccepted action listener DOES NOT properly work for outbound calls.
Upvotes: 0
Reputation: 902
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.
Upvotes: 0