TypeError: Cannot read property 'Digits' of undefined

I have used the code from Gather User Input via Keypad (DTMF Tones) in Node.js Twilio documentation for getting user input from the call.

but every time I dial in the numbers I'm just getting an error: "TypeError: Cannot read property 'Digits' of undefined"


    app.post('/voice', (request, response) => {
       const twiml = new VoiceResponse();

       function gather() {
         const gatherNode = twiml.gather({ numDigits: 1 });
         gatherNode.say('For sales, press 1. For support, press 2.');
       if (request.body.Digits) {
         switch (request.body.Digits) {
         case '1':
           twiml.say('You selected sales. Good for you!');
         case '2':
           twiml.say('You need support. We will help!');
           twiml.say("Sorry, I don't understand that choice.").pause();
      } else {



  • I have completed my review of your calls - we are flagging the webhook - https://81af-79-179-2-68.ngrok.io/gather - with an Error 11200, when triggering the TwiML below:

    <?xml version="1.0" encoding="UTF-8"?><Response><Gather action="/gather" method="POST" input="dtmf" numDigits="4"><Say>Hello from Visa, 200 dollars was sent from your credit card, we believe it was a fraudulent cash transfer, please dial in the 4 digits sent to your phone</Say></Gather><Redirect>/voice</Redirect></Response> 


    To that end, our next step is to review the - https://81af-79-179-2-68.ngrok.io/gather - the response we are receiving is included below:

    <!DOCTYPE html>
    <html lang="en">
    <meta charset="utf-8">
    <pre>TypeError: Cannot read property &#39;Digits&#39; of undefined<br> &nbsp; &nbsp;at C:\Users\Admin\Desktop\OTP Bot\index.js:37:20<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\layer.js:95:5)<br> &nbsp; &nbsp;at next (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\route.js:137:13)<br> &nbsp; &nbsp;at Route.dispatch (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\route.js:112:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\layer.js:95:5)<br> &nbsp; &nbsp;at C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\index.js:281:22<br> &nbsp; &nbsp;at Function.process_params (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\index.js:341:12)<br> &nbsp; &nbsp;at next (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\index.js:275:10)<br> &nbsp; &nbsp;at expressInit (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\middleware\init.js:40:5)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (C:\Users\Admin\Desktop\OTP Bot\node_modules\express\lib\router\layer.js:95:5)</pre>

    If you cannot get over the problem - I recommend the following as next steps:

    • Please review the documentation available at - https://ngrok.com/docs, there is an abundance of information freely available to you.
    • ngrok is a bridge to your local webserver - please do focus on the Error 11200.
      • Additionally, review the documentation here - 500 Internal Server Error, the 500 internal server error is a 'catch-all', which means the connection between your ngrok.io webhook and your private server is likely where things begin to break.
    • As you continually test, please keep an eye on your Twilio Console, specifically:

If this is an emergency, please contact Twilio Support. This is not an official Support channel. https://support.twilio.com/
Have an urgent question?
Please contact Twilio Support. This is not an official Support channel.
Contact Support