我有一个用node js编写的hello world alexa技能,并将其部署在heroku中。我必须使用websockets将响应发送到web ui(比如我本地机器中的html页面).Is这是可能的吗?
我的服务器代码-server.js
'use strict';
var AlexaAppServer = require( 'alexa-app-server' );
var server = new AlexaAppServer( {
httpsEnabled: false,
port: 8080
} );
server.start();下面是index.js
module.change_code = 1;
'use strict';
var alexa = require( 'alexa-app' );
var app = new alexa.app('Helloworld');
app.launch( function( request, response ) {
console.log(app);
//console.log(request);
response.say( 'Welcome to Welcome to helloworld.' );
});
app.error = function( exception, request, response ) {
console.log(exception)
console.log(request);
console.log(response);
response.say( 'Sorry an error occured ' + error.message);
};
app.intent('Helloworld',
{
"slots":[]
,"utterances":[
"hello alexa",
"hi alexa",
"how are you?"]
},
function(request,response) {
response.say("welcome user");
//send this same response to a webpage using socket
}
);
module.exports = app;发布于 2018-03-20 22:43:25
你是否正在尝试做html页面与alexa的互动。如果你是对的,你必须使用websocket,但你可以尝试AWS本身提供的API网关,在API网关中,你可以调用它到你的html页面,这个链接可能会对你有所帮助。https://blog.prototypr.io/using-voice-commands-to-control-a-website-with-amazon-echo-alexa-part-1-6-a35edbfef405
https://stackoverflow.com/questions/38063669
复制相似问题