5

I have trying to establish a call with javascript client:

function call() { 
// get the phone number or client to connect the call to 
   params = {"PhoneNumber": $("#number").val()}; 
   Twilio.Device.connect(params); 
} 

In incoming call back api we are got the call sid

Twilio.Device.incoming(function (conn) {
   alert(conn.parameters.CallSid);
});

And outgoing call back api we are not get the call sid:

Twilio.Device.connect(function (conn) { 
   alert(conn.parameters.CallSid); // Not working undefine
   $("#log").text("Successfully established call"); 
}); 

How to get call sid when twilio device connect successfully call(outgoing call)

Thanks

Megan Speir
  • 3,745
  • 1
  • 15
  • 25
Pratik Bhiyani
  • 2,489
  • 3
  • 17
  • 27
  • The above code works for me. Is it possible your capability token doesn't include outgoing calling? What do you see in the Twilio logs (https://www.twilio.com/user/account/log/calls) for that connection attempt? – liquidki Jul 25 '14 at 08:35
  • Add console.log(conn); after alert() to see whats in it – Ahmad Aug 12 '14 at 13:55
  • This remains a problem, and these comments aren't helping. Has anyone solved this? – Augie Gardner Aug 13 '14 at 17:09
  • Can you please guide me how did you integrate/require `twilio.js` file in the application? I have to do it with angular.js app. I can't require/include it and can't get the `Twilio` object to call methods – hmd Dec 04 '17 at 15:06

3 Answers3

1

In case anyone is still looking for this answer - I found the CallSid on the incoming request, and accessed this via the Server Side. I suppose you could actually grab this on the client as well... The CallSid is just a simple HTTP Request parameter when the call is initiated to your url!

0

I have asked Twilio the exact same question, and the answer I got is you don't get it on the client. You only get it on the server side for the outgoing call in the query params for the voice request URL.

Philip Pittle
  • 11,821
  • 8
  • 59
  • 123
not_fork
  • 3
  • 2
0

This works on my end.

  Twilio.Device.incoming(function (conn) {
    alert(conn['parameters']['CallSid']);
  });
Sunny
  • 1
  • 1