I have a twilio number. I would like to program a webhook for incoming calls to that number that handle the following scenario: the incoming call prompts the user to enter digits. I've tried using <Play>
to send DTMF tones, but the subsequent transcription of the call doesn't indicate the tones had any effect. Here's the relevant part of the webhook endpoint
const vr = new VoiceResponse();
vr.say('Hello');
vr.record({
maxLength: 60,
transcribe: true,
transcribeCallback: '/voice/text',
});
vr.play({
digits: 'wwww1',
});
vr.hangup();
res.setHeader('Content-Type', 'text/xml');
return res.status(200).send(vr.toString());
The transcription reads along the lines of "Hello, for ____ press one, for ____ press two... Goodbye".
I would like to record subsequent parts of the call after sending digits. Not sure what I'm doing wrong.
Turns out the answer was with order of TwiML verbs. According to the docs:
Any TwiML verbs occurring after a
<Record>
are unreachable.
After modifying code to
const vr = new VoiceResponse();
vr.say('Hello');
vr.play({
digits: 'wwww1',
});
vr.record({
maxLength: 60,
transcribe: true,
transcribeCallback: '/voice/text',
});
vr.hangup();
res.setHeader('Content-Type', 'text/xml');
return res.status(200).send(vr.toString());
The IVR tree progression worked as expected.