twilio-client.js icon indicating copy to clipboard operation
twilio-client.js copied to clipboard

[BUG] DTMFs are not correctly captured by Twilio when sent sequentially

Open acnovais opened this issue 3 years ago • 1 comments

  • [x] I have verified that the issue occurs with the latest twilio.js release and is not marked as a known issue in the CHANGELOG.md.
  • [x] I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • [x] I verified that the Quickstart application works in my environment.
  • [x] I am not sharing any Personally Identifiable Information (PII) or sensitive account information (API keys, credentials, etc.) when reporting this issue.

I have an implementation of a dialpad where the user takes in a phone call and inserts some DTMFs. Every time the user presses a digit, I send it directly to Twilio sdk, which means that if a user presses 1, 2, 3 it will call sendDigits 3 times with the different values. We noticed that when the user presses quickly enough, twilio doesn't capture the dtmfs correctly.

Diving into the code we found that you are adding an additional gap between digits (https://github.com/twilio/twilio-client.js/blob/master/lib/twilio/connection.ts#L869) besides the already present gap supported by the native api (https://github.com/twilio/twilio-client.js/blob/master/lib/twilio/connection.ts#L866). My assumption is that you need that gap to be there so that the media gateway correctly captures the dial tones. However, this extra gap is only there when the client application sends the digits as whole (in our example if we called sendDigits('123')).

This can be mitigated on the client application by buffering the digits and sending them to the twilio sdk as a whole but I believe this should be something for you to fix and possibly can be fixed by increasing the gap time used on the native API

Code to reproduce the issue:

twilioDevice.on('incoming', function(conn) {
  conn.on('accept', function() {
    setTimeout(function() {
      conn.sendDigits('1');
      conn.sendDigits('2');
      conn.sendDigits('3');
    }, 5000);
  });

  conn.accept();
});

Expected behavior:

Every digit gets captured and reproduced by Twilio

Actual behavior:

Digits are missed and not correctly reproduced by Twilio

Software versions:

  • [x] Browser(s): Chrome 85
  • [x] Operating System: MacOS
  • [x] twilio.js: latest
  • [x] Third-party libraries (e.g., Angular, React, etc.):

acnovais avatar Sep 22 '20 12:09 acnovais

Thank you @acnovais for reporting. We'll take a look. JIRA: https://issues.corp.twilio.com/browse/CLIENT-8102

charliesantos avatar Sep 23 '20 00:09 charliesantos