Search code examples
javascripttwilioivr

Respond to External IVT from Twilio


I've setup a simple call center using Twilio JavaScript library. I want to know how we can respond by key press when we call to external IVR systems. I found and following Twilio documentation of implementing our own IVR with Twilio Studio. But what I need here is as a client how we can respond to external IVR systems by pressing '1' for Sales, '2' for promotions, etc. ?

TIA


Solution

  • Twilio developer evangelist here.

    You can play DTMF tones using Twilio in two ways.

    You can either do so at the start of creating a call by sending the SendDigits parameter with the digits you want to send (and ws for 0.5s pauses). For example:

    client.calls
      .create({
         url: 'http://demo.twilio.com/docs/voice.xml',
         to: '+15558675310',
         from: '+15017122661',
         sendDigits: 'wwww194'
       })
    

    Will create a call, when the call connects it will wait 2 seconds (4 * w == 4 * 0.5s) and then send the tones for 194.

    Alternatively, if you are in the middle of a call you can respond to questions using DTMF tones with the <Play> TwiML element using the digits attribute, like this:

    const response = new VoiceResponse();
    response.play({
        digits: 'wwww194'
    });
    

    Let me know if that helps.