0

I've developed a web that connect two persons into a call following this tutorial: https://www.twilio.com/docs/tutorials/click-to-call-node-express and everything is working fine.

Now I need to gather 1 digit of the callee in order to execute a command.

Reading the Twilio documentation it seems I can't use Gather until the Dial verb is over, but this way the call is closed and the callee can't digit anything.

I tried this without success, the dial works fine but the digits callback is never executed:

twimlResponse.say(
    'Please wait for the other person to join the call'
  );

  twimlResponse.dial({
    timeLimit: 30
  })
  twimlResponse.dial(to_number)

  const gather = twimlResponse.gather({
    input: 'dtmf',
    timeout: 30,
    numDigits: 1,
    action: url // the url is the callback that should handle the digit entered
  });

Is it a limitation of Twilio? any workaround or alternative call strategy?

Fabrizio D'Ammassa
  • 4,729
  • 25
  • 32
  • Hey Fabrizio, do you need to perform the gather on the end of the callee before they are connected, or during the conversation? – philnash Aug 29 '17 at 10:17
  • I need to perform the gather at the end of the call, as a final action the callee should perform after talking to the other party. – Fabrizio D'Ammassa Aug 29 '17 at 15:21

1 Answers1

1

I believe you need to send an url with the number you dial and have that URL respond with the TwiML you want to drive the interaction with the callee. From https://www.twilio.com/docs/api/twiml/number:

The 'url' attribute allows you to specify a url for a TwiML document that will run on the called party's end, after she answers, but before the parties are connected. You can use this TwiML to privately play or say information to the called party, or provide a chance to decline the phone call using <Gather> and <Hangup>.

So something like this:

const dial = twimlResponse.dial({
  timeLimit: 30
});
dial.number({
  url: urlToGather // respond to this URL with your <Gather> TwiML
}, to_number);
user94559
  • 59,196
  • 6
  • 103
  • 103
  • Thanks smarx, the solution doesn't fit to my needs because I need to gather the digit at the end of the call. – Fabrizio D'Ammassa Aug 29 '17 at 15:21
  • I'm not sure that can be done. [The action attribute](https://www.twilio.com/docs/api/twiml/dial#attributes-action) seems most promising, but that seems specific to the "dialed party" (callee) hanging up. – user94559 Aug 29 '17 at 16:45