-1

I have the below method. Currently is just calls up an external phone number and says "Welcome". I cannot understand how to connect a twilio number with an external phone number by voice? Lots of example of how to do text-to-voice but not much on voice to voice. Any pointers appreciated.

public function test_call(){
    $this->account_sid = 'AC-account_sid';
    $this->auth_token = 'myauth_token';
    $this->client = new Client($this->account_sid, $this->auth_token);
    $call =  $this->client->account->calls->create(
      '+81xxxxxxxxxx', // Destination phone number
      '+81yyyyyyyyyy', // Valid Twilio phone number
      array(
          "record" => false,
          "url" => "http://development.example.com/gomi.xml")
      );
    if($call) {
      echo 'Call initiated successfully';
    } else {
      echo 'Call failed!';
    }
}

Contents of gomi.xml

 <Response>
 <Say voice="alice">Welcome</Say>
 </Response>
spreaderman
  • 918
  • 2
  • 10
  • 39

1 Answers1

2

If you want to connect your call there to another number, then you need to look at the <Dial> TwiML verb.

You could, for example, update your gomi.xml to:

<Response>
  <Dial>
    <Number>+XXXXXXXXXXXX</Number>
  </Dial>
</Response>

Then, when the initial call connects it would trigger another call to the number inside the <Number> tags, connecting the two callers.

Take a look at the documentation for <Dial> for more information.

philnash
  • 70,667
  • 10
  • 60
  • 88