我试图建立一个ASK(Alexa的技术工具包)的应用程序,因为他们进来,基本读出的消息。你怎么能在Alexa的技能套件流反应(ASK)
我已经尝试的代码测试这个到目前为止是:
function handleObserveFlowIntentRequest(intent, session, response) {
var callback = function (message) {
response.tell({
speech: message,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
});
};
callback("One Observe Flow");
callback("Two Observe Flow");
}
我只能够得到第一回调输出"One Observe Flow"
最终我想要的回应基本上做这样的事情:
function handleObserveFlowIntentRequest(intent, session, response) {
var callback = function (message) {
response.tell({
speech: message,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
});
};
var jsonStream = new EventSource(::myApiUrl::);
jsonStream.onmessage = function (e) {
callback(e.data.message);
}
}
使用[event-source-stream](https://www.npmjs.com/package/event-source-stream)。 –
事件源与事件源流之间的区别是什么,以及ASK中的不同之处如何? –
我不知道ASK,但''''''''''''''''只有在浏览器中'''node.js''中不可用。所以'''''''''EventSource''和'''''''''''''''''''npm'''填充将''第一个换成流api,这样你就可以'''''' '''.on('data',...'''为它。 –