【发布时间】:2019-07-13 02:59:06
【问题描述】:
我已经开始使用 CodeStar 和 Nodejs 制作一个简单的 Alexa 技能,我的技能可以告知用户 Web 系统当前是否仍然可用,如果当前有任何事件或服务中断。我从http://statuspage.io 以 JSON API 的形式获取所有数据。
我遇到的问题是,我的LaunchRequestHandler 工作正常,我问的第一个 Intent 也是如此,但是当我问第二个 Intent(紧接在第一个 Intent 之后)时,这就是我的技能中断和输出(在 Alexa 开发者控制台内):<Audio only response>。
下面我粘贴了我的技能中的代码。
// model/en-GB.json
"intents": [{
"name": "QuickStatusIntent",
"slots": [],
"samples": [
"quick status",
"current status",
"tell me the current status",
"what's the current status",
"tell me the quick status",
"what's the quick status"
]
},
{
"name": "CurrentIncidentIntent",
"slots": [],
"samples": [
"incidents",
"current incident",
"is there a current incident",
"tell me the current incidents",
"what are the current incidents",
"are there any current incidents"
]
}]
// lambda/custom/index.js
const QuickStatusIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'QuickStatusIntent';
},
async handle(handlerInput) {
let speechText = await getNetlifyStatus();
return handlerInput.responseBuilder
.speak(speechText)
.getResponse();
}
};
const CurrentIncidentIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'CurrentIncidentIntent';
},
async handle(handlerInput) {
const result = await getSummary();
const speechText = `There are currently ${result.incidents.length} system incidents`;
return handlerInput.responseBuilder
.speak(speechText)
.getResponse();
}
}
我最初的想法是删除 .getResponse(),因为它可能一直在等待响应,但是,它似乎无法正常工作。
【问题讨论】:
标签: javascript node.js alexa alexa-skills-kit