Shreyas
Shreyas

Reputation: 1410

Issues testing twilio webrtc client for conference using demo account

I created an asp.net webpage and I am using a twilio trial account (twilio client) to test click to conference. When I get connected, it plays the twilio demo account spiel and then asks me to click any number to continue. Unfortunately since I am testing this on a laptop, it doesn't recognize anything and disconnects and doesn't connect me to the conference (I don't see any entries in the log for this). I know the conference works as I can directly dial the phone number, listen to the message, click a number, and then hear the conference enter sound.

How can I continue using the trial account for developing this app?

Per Devin Rader (Twilio Evangelist), I need to use senddigits method. Here is my updated code that still does not work

<script type="text/javascript"
        src="//static.twilio.com/libs/twiliojs/1.2/twilio.min.js"></script>
<script type="text/javascript"
        src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript">

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

        Twilio.Device.ready(function (device) {
            $("#log").text("Ready");
        });

        Twilio.Device.error(function (error) {
            $("#log").text("Error: " + error.message);
        });

        Twilio.Device.connect(function (conn) {
            $("#log").text("Successfully established call");
        });

        function call() {
            Twilio.Device.connect();
        }

        function senddigits() {
            Twilio.Device.sendDigits("5");
        }
        function mute() {
            Twilio.Device.mute(true);
        }
        function unmute() {
            Twilio.Device.mute(false);
        }
</script>

<div class="row">
    <div class="col-md-4">
            <button class="btn btn-default" onclick="call();">
                Ready! 
            </button>
    </div>
    <div class="col-md-4">
        <a class="btn btn-default" href="tel:1234567890">Call!</a>
    </div>
    <div class="col-md-4">
            <button class="btn btn-default" onclick="senddigits();">
                Send Digits
            </button>
    </div>
    <div class="col-md-4">
            <button class="btn btn-default" onclick="unmute();">
                Unmute
            </button>
    </div>
    <div class="col-md-4">
            <button class="btn btn-default" onclick="mute();">
                Mute
            </button>
    </div>
    <div class="col-md-4" id="log">Loading...</div>

Upvotes: 0

Views: 639

Answers (1)

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

The sendDigits function of Twilio Client's Connection object lets you send DTMF tones to simulate pressing numbers on a dial pad, so you could just add another button (or buttons) to your page that.

In the example below I'm putting the connection object passed into the connect function into a global variable, then usaing that variable in other functions to send DTMF tones, and mute/unmute the connection.

<script type="text/javascript">

    var connection;

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

    Twilio.Device.ready(function (device) {
        $("#log").text("Ready");
    });

    Twilio.Device.error(function (error) {
        $("#log").text("Error: " + error.message);
    });

    Twilio.Device.connect(function (conn) {
        $("#log").text("Successfully established call");

        connection = conn;
    });

    function call() {
        Twilio.Device.connect();
    }

    function senddigits() {

        if (connection!=null)
            connection.sendDigits("5");
    }
    function mute() {
        if (connection!=null)
            connection.mute(true);
    }
    function unmute() {
        if (connection!=null)
            connection.mute(false);
    }
</script>

Hope that helps.

Upvotes: 1

Related Questions