1
votes

I try to call my phone number by Twilio. I manage to do that by call action method:

public ActionResult Call(string toNumber) {
    client = new TwilioRestClient(Settings.AccountSid, Settings.AuthToken);        
    var result = client.InitiateOutboundCall(Settings.TwilioNumber, toNumber, "http://twimlets.com/message?Message%5B0%5D=http://demo.kevinwhinnery.com/audio/zelda.mp3");     
    if (result.RestException != null) {
        return new System.Web.Mvc.HttpStatusCodeResult(500, result.RestException.Message);
    }    
    return Content("Call enroute!");
}

When I answer the phone the mp3 specified in the url is played. I want live 2-way audio. In some examples from Twilio like : https://www.twilio.com/docs/quickstart/csharp/client/outgoing-calls I see usage of capability token:

var capability = new TwilioCapability(accountSid, authToken);
    capability.AllowClientOutgoing(appSid);
    capability.AllowClientIncoming("jenny");
    string token = capability.GenerateToken();

and Twilio Device: Twilio.Device.setup('@token');.

Why am I even able to make phone call without generating capability token in my example? Can I somehow create Twilio.Device in C# not javascript? Should I pass capability token as model from controller?

1

1 Answers

2
votes

The Twilio.Device namespace is exclusive to the Twilio Client libraries (For iOS, Android, or the JS library for a web browser). If you think of your smart phone or your web browser as a possible device for voice communications, it'll be a little bit easier to do what you want to do. If you want to be able to communicate with your phone on the computer, you will have to generate the capability token in .Net, and then setup your device in the browser so that you can talk through your computer.

Read more here about capability tokens: https://www.twilio.com/docs/client/capability-tokens