twiliotwilio-apitwilio-phptwilio-twimltwilio-click-to-call

Twilio Make call and send digits multiple times using DTMF


Scenario: I want to dial a number where an IVR is setup. That has press 1 for English and press 2 for Spanish. Once a number is chosen then it asks for 6 digit key. How I can pass the next 6 digits using DTMF?

I had read the documentation thoroughly and searched on StackOverflow too but didn't got the relevant data.

What I tried is;

$twilio = new Client("AC8b2cc96be2a8dbc059f2908exxxxxxxx", "88db8eeb71124a3effd6c196xxxxxxxx");
$from = "+1289724xxxx";

$to = "+1289670xxxx";

$call = $twilio->calls
               ->create($to, // to
                        $from, // from
                        [
                            "method" => "GET",
                            "sendDigits" => "wwwwwwwwww1",
                            "sendDigits" => "wwwwwwwwwwwwwwwwww123456", // Whithout this line it's working for first digit press
                            "url" => "http://demo.twilio.com/docs/voice.xml"
                        ]
               );

print($call->sid);

I am trying it using PHP Rest API. https://www.twilio.com/docs/voice/make-calls#example-3 I had also read this question: How to send digits in twilio call


Solution

  • You can't send the same parameter twice, instead, you should combine that sendDigits parameter into one string, like this:

    $call = $twilio->calls
                   ->create($to, // to
                            $from, // from
                            [
                                "method" => "GET",
                                "sendDigits" => "wwwwwwwwww1wwwwwwwwwwwwwwwwww123456",
                                "url" => "http://demo.twilio.com/docs/voice.xml"
                            ]
                   );
    

    Then it will wait, press 1, wait some more then press 123456.