0

When I respond to a Twilio call with a webhook how do I wait for a response?

I'm using node.js. I can't seem to find it in the docs. Sorry if I missed it.

What I'm looking for is a short question/answer session. Respond with a question - then listen for the reply.

Bela Vizy
  • 1,133
  • 8
  • 19
  • 1
    Are you after a response from the caller? By voice or dial tones? Have you checked out [``](https://www.twilio.com/docs/api/twiml/gather)? – philnash Oct 23 '18 at 06:24

2 Answers2

1

You don't wait for it. It will post another response to your server when something happens. It's the same as providing a document to a web browser and then waiting for the user to do something to go back to the server. You can tie requests together by the CallSid.

JOTN
  • 6,120
  • 2
  • 26
  • 31
0

I should have spent more time reading. Indeed the <Gather> is the solution.

In Node.js you need something like this (using the SDK):

twiml.play({}, this.audio); 
if (this.outputSpeech) { 
    twiml.say(this.outputSpeech); 
}
twiml.gather({ 
    input: "speech", 
    timeout: 3, 
    method: "GET" 
});

There is plenty more on the Twilio blogs.

Bela Vizy
  • 1,133
  • 8
  • 19