0

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>
Shreyas
  • 1,410
  • 3
  • 11
  • 15

1 Answers1

1

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.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32
  • Thanks Devin. So for the trial account, should I just wait for a few seconds and then send digits? If I understand it right, sending digits while the system is playing the message does not help. Is there a way I can do this via the twiml? – Shreyas Jul 24 '14 at 17:03
  • You should be able to do by pausing and then using sendDigits. I'm actually not sure if we start the before playing the trial message. re: doing it via TwiML: I don't think there is way to do it via TwiML. If you were using to connect to a , you could use the sendDigits parameter but thats not an option on the noun. – Devin Rader Jul 24 '14 at 19:27
  • Thanks. Also, due to the browser support issue I decided to make a WPF application where one clicks to join a conference. I used this example https://www.twilio.com/docs/quickstart/csharp/rest/call-request but I think this is making a call to a number outside from twilio. How can I let someone click a button in an app and just join a conference? – Shreyas Jul 25 '14 at 04:05
  • I added a few more buttons to the prototype asp.net app for send digits, mute and unmute. I have updated the code in the original question. Could you please let me know if this is correct? When I click on send digits, it does not do anything and the call gets disconnected. I confirmed that if I put an alert in senddigits, it shows the alert. – Shreyas Jul 28 '14 at 14:14
  • the sendDigits and mute functions are on the Connection object, not the Device object. I added a sample to my answer. – Devin Rader Jul 28 '14 at 15:29
  • Thanks Devin and apologize for overlooking something like this. I'll try this tonight and let you know. – Shreyas Jul 28 '14 at 16:00
  • Worked perfectly. Thanks Devin – Shreyas Jul 29 '14 at 14:59