已经走了两天的不同路线了,还搞不清楚。也许有人能对我的问题有所了解。我正在尝试运行一个僵尸服务器,它连接到多个plaform,并且已经有了大约5种工作。
我现在也在尝试整合Alexa。我看到Alexa请求进入我的服务器(因此Alexa技能和端点配置是正确的),但是这也花了我相当长的时间,因为Amazon显然只向端口443发送通信量,所以允许在Amazon中心定义另一个端口号,但是什么也不做.好的!通过添加一个带有端口转发的负载均衡器来解决。
真正的问题。我试图使用alexa-app作为我的框架,从以下例子:
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 当我在一个文件中安装我的快速服务器,然后使用中间件函数在第二个文件中设置我的侦听器时,我不知道如何使用它.类似于:
app.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());listener.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>;
}谢谢你的帮助或指点!
发布于 2017-07-28 21:33:41
最后,我设法通过epxress路由器将我的主app.js连接到alexa的getMessagingHandler功能。因此,在app.js路由中,您的alexa在侦听器中到getMessagingHandler,然后在侦听器中:
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;在主app.js中:
app.use('/alexa', controller.Bot.Alexa.Listener.getMessagingHandler());https://stackoverflow.com/questions/43192818
复制相似问题