Search code examples
javascriptruby-on-railsrubytwiliovoip

Getting CallSid from Twilio in ougoing calls using js


I would like to know if there is any way to retrieve CallSid using TwilioJS library from an outgoing call done from a Browser to a Phone. The think is that I'm not able to post anything from my client to my server since I don't have any id of the call.

I've tried to find out the parameters of the connection object:

var connection = Twilio.Device.connect()

But no CallSid appears there. Does anyone know how can a get this parameter, or something that lets me to identify the ougoing call that I've just done from js library?

Thanks :D


Solution

  • As seen in https://www.twilio.com/docs/client/connection, connection should be a Twilio.Connection object which has a property named parameters with a CallSid attribute both for incoming and outgoing connections.

    It is probably only available after the connection is made, so you should use an event handler for connect event:

    Twilio.Device.connect(function(connection) {
        var callSid = connection.parameters.CallSid;
    });