1
votes

I'm a new developer and am researching implementing Twilio into my companies application. In researching and working with Twilio's Voice API I've gotten the basic programmable voice running as seen below.

I know the URL contains the basic TWIML demo instructions for what Twilio should do with the call, my question is what if I just want a regular two-way call? No programmable voice or automated response just two people talking until one hangs up. Is that even possible with Twilio? Thanks in advance.

    client.calls
      .create({
         url: 'http://demo.twilio.com/docs/voice.xml',
         to: `+1${req.body.to}`,
         from: `+1${req.body.from}`
       })
      .then(call => {
          console.log(call.sid);
        }).catch(next)
};
1

1 Answers

1
votes

In your example, when the recipient answers the call, the code at url: 'http://demo.twilio.com/docs/voice.xml' will run. That's some generic TwiML provided by Twilio.

You'll need to change that to either your webhook (hosted on your server) or with a TwiML Bin (hosted at Twilio) (https://www.twilio.com/console/runtime/twiml-bins).

To connect two or more people you could put them in a conference if you respond with XML (TwiML) like so:


<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial>
    <Conference>Room 1234</Conference>
  </Dial>
</Response>

For two people you would run your Node.js code twice changing the to: phone number for each recipient.


Docs:

https://www.twilio.com/docs/voice/twiml/conference

https://www.twilio.com/docs/voice/api/conference



<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial>415-123-4567</Dial>
</Response>

where 415-123-4567 is the number for the second person.