2

We're developing a Twilio programmable voice app that can select from a list of persons, and place an outbound call to their regular telephone number.

Once the call is connected, we want to be able to speak to the party and then gather dtmf input from the call recipient in order to trigger some specific TwiML code based on the dtmf code entered.

Twilio programmable voice docs don't specify how to gather dtmf input from a call recipient on an outbound call, but I would like to think this is in some way possible. Any advice or ideas would be appreciated!

2 Answers2

1

Twilio developer evangelist here.

Outbound calls with Twilio are actually very similar to inbound calls. When you get an inbound call, Twilio makes the webhook request to find out what to do next and you respond with TwiML, for example a <Gather> when you want to take information.

When you make an outbound call, you start the call with the REST API and then when the call connects Twilio makes a webhook request to your URL. At this stage, you respond with TwiML to tell Twilio what to do and you can respond with a <Gather> at this stage too.

Does that help?

philnash
  • 70,667
  • 10
  • 60
  • 88
  • I appreciate your insight. When the outbound call is connected, at what point will the specified TwiML verb be active? Is the receiving party able to input dtmf feedback at any point during an active call, or is the TwiML "listener" only executed prior to the audio call connection? – Rob Carlisle Dec 17 '18 at 14:35
  • Oh, are you trying to gather input during a two way call? – philnash Dec 17 '18 at 22:25
  • 2
    Yes, user of the Twilio app will select a name and dial it from a smart device. The app then dials out to a real human (cell or landline number). We want to establish a two-way voice conversation, and also have the ability to gather DTMF input from the call recipient that will execute some TwiML code and perform an external action. Currently, the app is generating the call, but we don't know how to go about gathering dtmf input from the recipient. – Rob Carlisle Dec 18 '18 at 02:45
  • Ah, sorry, didn’t get that it was during a two way call. `` only works with a single leg. You could build this as a conference call and allow the user to press `*` (with ``s `hangUpOnStar` attribute) to drop out of the conference, direct to a ``, enter the dtmf tones and then rejoin the conference. If this is related to taking payments over the phone, you could also check out [`` ](https://www.twilio.com/pay) which is built to take payment details during a call. – philnash Dec 18 '18 at 03:15
0

If you are using Twilio Client then you can send digits with the following code:

var connections = Twilio.Device.activeConnection();
connections.sendDigits("12");
Joshua Wade
  • 4,755
  • 2
  • 24
  • 44
sajid
  • 1
  • 1