【问题标题】:Using websockets with Alexa skills kit将 websockets 与 Alexa 技能套件一起使用
【发布时间】:2016-06-27 21:37:34
【问题描述】:

我有一个用 node js 编写的 hello world alexa 技能并将其部署在 heroku 中。 我必须使用 websockets 将响应发送到 web ui(比如我本地机器中的 html 页面)。这可能吗?

我的服务器代码-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;

【问题讨论】:

  • 感谢乔纳森的回复。我已经使用 alex-app npm 模块来构建技能。这怎么可能,示例代码 sn-ps 会有所帮助。谢谢!
  • 我认为没有人会回答这个问题,因为到目前为止您还没有向我们展示您的尝试。
  • 我已添加代码

标签: alexa alexa-skills-kit alexa-skill


【解决方案1】:

您是否正在尝试与 alexa 交互的 html 页面。如果是,你是对的,你必须使用 websocket,但你可以尝试 AWS 本身提供的 API 网关,在 API 网关中你可以将它调用到你的 html 页面,这个链接可能会对你有所帮助。 https://blog.prototypr.io/using-voice-commands-to-control-a-website-with-amazon-echo-alexa-part-1-6-a35edbfef405

【讨论】:

  • 请将所有相关信息添加到您的答案中。如果链接页面上的内容发生变化,它可能会变得无用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-02-27
  • 1970-01-01
  • 1970-01-01
  • 2018-08-17
  • 2019-07-03
  • 2017-04-21
  • 2019-05-25
相关资源
最近更新 更多