I'm trying to use a function in twilio studio to forward a call to a phone number with an extension. The
Twilio Docs on using sendDigits gives this example code in node.js:
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();
const dial = response.dial();
dial.number({
sendDigits: 'wwww1928'
}, '415-123-4567');
console.log(response.toString());
but dial.number gives the error message "twiml.dial.number is not a function". And when I call my twilio number, I hear a message that says "the number you dialed is not a working number".
If I remove the number so that it reads:
dial({
sendDigits: 'wwww1928'
}, '415-123-4567');
then I can call my twilio number and get through to the phone number it's supposed to connect me to, but it is not dialing the sendDigits. So it's only doing what a "Connect Call to" widget would do in studio, which is not helpful to me. I need it to dial the sendDigits so that I can call an extension.
Here's my current studio flow. There are other widgets, but they're disconnected at the moment and irrelevant to the issue so I left them off the screenshot. This set up just uses one "Run Function" to pick the number to forward someone to and another "Run Function" to dial the number with an extension (which is not working).
Any tips on getting sendDigits to work would be really appreciated.