I have created an application using https://www.twilio.com/docs/howto/twilio-client-browser-soft-phone as the template. I am trying to log the CallSid for incoming and outgoing calls so that I can tag calls locally and use the Callsid to link between my local data and twilio's call store. I am able to get the CallSid for incoming calls easily with:
Twilio.Device.incoming(function (conn) {
if (confirm('Accept incoming call from ' + conn.parameters.From + '?')){
connection=conn;
conn.accept();
callsid = connection.parameters.CallSid;
}
else {
connection=conn;
conn.reject();
}
});
However, I can't seem to get it from any outgoing call initiated by the softphone. I have tried here:
$("#call").click(function() {
params = { "tocall" : $('#tocall').val()};
connection = Twilio.Device.connect(params);
callsid = connection.parameters.CallSid;
});
and here:
Twilio.Device.connect(function (conn) {
$('#status').text("Successfully established call");
toggleCallStatus();
callsid = connection.parameters.CallSid;
// And also tried
callsid = conn.parameters.CallSid;
});
However, both of these return undefined. I saw on https://www.twilio.com/docs/client/connection that the CallSid is set in the Outgoing .parameters towards the bottom of the page, so I assume it should be available in one of these function calls.
Is the CallSid available for calls originated by the client? And if so, where/how do I access it?