twiliotwilio-twiml

Sending DTMF through a stream


I'm setting up some automated tests to ensure that our bot is working.

Currently I'm sending .wav files into the call and it's working fine, but at some point we use gather to receive DTMF input from the user. This is working using connect with stream so I can send and receive data from the call in real time during the test.

Sending the DTMF as audio doesn't work though(as expected, since the docs explain that this data goes through a different channel).

Is is possible to to this in a simple way ? Right now I'm thinking of starting a conference with USER + BOT (SUT) + another bot that will send the DTMF with play when necessary. But this is getting too complex.


Solution

  • The solution that I found was to update the current call TwiML to play digits and then recreate the stream. Something like:

    <Response>
      <Play digits="<DTMF>"> </Play>
      <Connect>
        <Stream url="wss://<websocket server url>"> </Stream>
      </Connect>
    </Response>
    

    It did work but its a little slow because of the reconnection phase.

    I'll leave the question unanswered to check for some other solutions.