Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
Amazon Alexa, aplicación de alexa y middleware

He estado yendo por rutas diferentes durante 2 días y no puedo resolverlo. Tal vez alguien pueda arrojar algo de luz sobre mis problemas. Estoy tratando de ejecutar un servidor de bots que se conecta a múltiples plataformas y ya tengo alrededor de 5 funcionando.

Ahora también estoy tratando de integrar a Alexa. Veo solicitudes de Alexa que ingresan a mi servidor (por lo que la habilidad de Alexa y la configuración del punto final son correctas), sin embargo, esto también me tomó bastante tiempo ya que aparentemente Amazon solo envía tráfico al puerto 443, por lo que se permite definir otro número de puerto en el centro de desarrollo de Amazon. , pero no hace nada... ¡bien! Resuelto agregando un balanceador de carga con reenvío de puertos.

Sobre la verdadera pregunta. Estoy tratando de usar alexa-app como mi marco del siguiente ejemplo:

 var express = require("express"); var alexa = require("alexa-app"); var express_app = express(); var app = new alexa.app("sample"); app.intent("number", { "slots": { "number": "AMAZON.NUMBER" }, "utterances": ["say the number {-|number}"] }, function(request, response) { var number = request.slot("number"); response.say("You asked for the number " + number); } ); // setup the alexa app and attach it to express before anything else app.express({ expressApp: express_app }); // now POST calls to /sample in express will be handled by the app.request() function // GET calls will not be handled // from here on, you can setup any other express routes or middleware as normal

La parte que no puedo entender es cómo usar esto cuando configuro mi servidor express en un archivo y luego quiero usar la función de middleware para configurar mi oyente en el segundo archivo... algo como:

aplicación.js:

 var express = require("express"); var express_app = express(); https.createServer({ key: fs.readFileSync(key), cert: fs.readFileSync(cert), ca: fs.readFileSync(ca) }, app).listen(port, function () { console.log("http: api server listening on port " + port); }); app.use('/alexa', controller.Bot.Messenger.Listener.botMiddleWare());

oyente.js:

 var alexa = require("alexa-app"); var app = new alexa.app("sample"); bot.botMiddleWare = function botMiddleWare () { return <return function to connect to express in app.js>; }

Gracias por cualquier ayuda o consejos!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Al final logré conectar mi app.js principal a través del enrutador epxress a la función getMessagingHandler de la aplicación alexa. Entonces, en app.js enruta tu webhook de alexa al getMessagingHandler en tu oyente y luego en el oyente:

 var bot = new alexa.app('my_bot'); bot.getMessagingHandler = function getMessagingHandler() { return function (req, res) { req.on('end', function(){ var jsonData = JSON.parse(requestBody); if(jsonData.request.type == "LaunchRequest") { // handle response here } } } } module.exports = bot;

En la aplicación principal.js:

 app.use('/alexa', controller.Bot.Alexa.Listener.getMessagingHandler());
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!