【发布时间】:2018-12-04 21:36:20
【问题描述】:
我正在开发一项 Alexa 技能,该技能需要用户必须连续回答多个问题的多步骤对话。我正在尝试通过检查插槽是否已确认并返回addElicitSlotDirective 的响应来添加单个插槽提示,如果不是:
这是整个请求处理程序:
const isIntentRequest = require('../utils/isIntentRequest');
const sound = require('../utils/sound');
const loadUser = require('../utils/loadUser');
const loadWordByIndex = require('../utils/loadWordByIndex');
module.exports = {
canHandle(handlerInput) {
return isIntentRequest(handlerInput, 'NewWordPathIntent');
},
async handle(handlerInput) {
const user = await loadUser(handlerInput);
const { wordIndex } = user;
const word = await loadWordByIndex(wordIndex);
const slots = handlerInput.requestEnvelope.request.intent.slots;
if(!hasAnswered('NewWordEnglishAnswer')) {
return handlerInput.responseBuilder
.speak('New Word English Answer word ' + word)
.reprompt('New Word English Answer word ' + word + ' reprompt')
.addElicitSlotDirective('NewWordEnglishAnswer')
.getResponse();
}
return handlerInput.responseBuilder
.speak('You answered the new word english question')
.getResponse();
function hasAnswered(slotName) {
const slot = slots[slotName];
if(!slot) throw new Error(`Invalid answer slot: "${slotName}"`);
return slot.confirmationStatus === 'CONFIRMED';
}
},
};
这似乎主要是有效的。处理此意图后,Alexa 会回复:New Word English Answer word evidence,这是正确的,但随后她会立即使用 There was a problem with the requested skill's response 跟进并终止会话。
为什么会这样?如果正在输出响应,那么响应有什么问题?
【问题讨论】:
标签: javascript node.js alexa-skills-kit alexa-skill