Hiren
Hiren

Reputation: 1435

Twilio JS send digits in VoIP call

I want to implement one functionality in VoIP call using twilio. Like if someone is calling to the customer care numbers and in that case they have to dial some numbers to navigate like dial some number choose language and dial some number to talk to representative.

So, to implement this in my application with VoIP call, I have tried this so far.

Here is my generated TwiML response at the time of VoIP start

<Response>
    <Dial timeLimit="7200" callerId="+19782880482" record="record-from-answer-dual">
        <Number statusCallbackEvent="initiated ringing answered completed" statusCallback="http://0affe80b.ngrok.io/call/twilio/events" statusCallbackMethod="POST"></Number>
    </Dial>
    <Record timeout="10" maxLength="7200"/>
</Response>

And in frontend part, on each digit press I am sending a digit to current active connection like this,

function onNumberPress(number){
   var connection = Twilio.Device.activeConnection();
   connection.sendDigits(number);
}

But, now at the time of sendDigits function, I am getting this error

TypeError: a.match is not a function
at a.sendDigits (twilio-1.3.21.min.js:19)

Note: I am able to get active connection here. After surfing I found that I need to supply Gather keyword in TwiML. But do I need to pass those in this case? I think its not needed in My described case.

Am I on right track? Is this possible to achieve? If then what am I missing here?

Upvotes: 2

Views: 1050

Answers (1)

philnash
philnash

Reputation: 73090

Twilio developer evangelist here.

The connection.sendDigits function takes a string as an argument (as it can be any digit as well as # or *). I think you may be passing a number to it instead. Try ensuring that the digits you send are strings.

Upvotes: 3

Related Questions