Search code examples
twiliotwilio-programmable-voice

Make an outgoing call to a number and listen for responses


I would like to initiate an outgoing call from twilio to a number provided by a service like nexmo and be able to listen to the response. Based on the voice message back from the receiver, i would like to determine my response

I have gone through the documentation, and from what i can make out, the outgoing call does not give me an access to the incoming stream. The Call object allows me to control the call, but not based on the voice response

client.calls
      .create({
         url: 'http://demo.twilio.com/docs/voice.xml',
         to: '+15558675310',
         from: '+15017122661'
       })
      .then(call => console.log(call.sid));

The call object does not provide me a way to access the conversation audio.

Overall, I would like the call to be initiated and my caller program to get access to the response voice messages that it can parse and then determine the next response.

Should i consider SIP for this scenario, since the destination number will also be having a SIP endpoint?


Solution

  • I was able to achieve this with the standard Twiml

    The Gather verb of twilio will wait to receive voice packet and then perform speech recognition on it and send back the text.

    In response to this callback, i am sending back the next audio to play and immediately followed by the next Gather.