prasannaboga
prasannaboga

Reputation: 1014

Twilio javascript client callback on call answer

I am using Twilio JavaScript client. I am able to make calls, capture callback events, connect, and disconnect. How do I implement a callback when a call is answered? I need to show a call timer after answering the call.

Upvotes: 5

Views: 941

Answers (1)

Louis Lewis
Louis Lewis

Reputation: 1298

The Twilio js client has a Device property which has the following methods that you can use.

Twilio.Device.incoming(softPhoneIncoming);
Twilio.Device.connect(softPhoneConnect);

function softPhoneIncoming(conn) {
        console.log(conn.parameters.From); // who is calling
        conn.accept(); //This will accept the incoming phone call
    }

function softPhoneConnect(conn)
    {
        // Called for all new connections, you could start the timer here
    }

Upvotes: 1

Related Questions