Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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"

Thanks!

code:

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.');
     twiml.redirect('/voice');
   }
   if (request.body.Digits) {
     switch (request.body.Digits) {
     case '1':
       twiml.say('You selected sales. Good for you!');
       break;
     case '2':
       twiml.say('You need support. We will help!');
       break;
     default:
       twiml.say("Sorry, I don't understand that choice.").pause();
       gather();
       break;
    }
  } else {
gather();
}

response.type('text/xml');
response.send(twiml.toString());
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Is the below added after you initialize Express?

// Body Parser Middleware
app.use(express.urlencoded({ extended: false }));

Something like:

const express = require('express')

const app = express()

app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

app.post('/profile', function (req, res, next) {
  console.log(req.body)
  res.json(req.body)
})

It looks like the documentation has it, so maybe it was accidentally omitted in your code?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda