多转对话框:无法转为完成状态

时间:2018-10-17 17:26:38

标签: alexa alexa-skills-kit alexa-skill alexa-slot alexa-sdk-nodejs

我正在尝试开发一种需要多轮对话的技能。到目前为止,Alexa技能能够准确提示并捕获插槽。仅某些插槽需要确认。在捕获了最后一个时隙(时间)的值之后,它将触发错误处理程序,而不是进入COMPLETE状态。

出现错误时,附加的是JSON输出

{
"body": {
    "version": "1.0",
    "response": {
        "directives": [
            {
                "type": "Dialog.Delegate",
                "updatedIntent": {
                    "name": "AddNewMedIntent",
                    "confirmationStatus": "NONE",
                    "slots": {
                        "dosage": {
                            "name": "dosage",
                            "value": "2",
                            "confirmationStatus": "NONE"
                        },
                        "medication": {
                            "name": "medication",
                            "value": "Xanax",
                            "confirmationStatus": "CONFIRMED"
                        },
                        "time": {
                            "name": "time",
                            "value": "07:00",
                            "confirmationStatus": "NONE"
                        }
                    }
                }
            }
        ]
    },
    "sessionAttributes": {},
    "userAgent": "ask-node/2.1.0 Node/v8.10.0"
}
}

这是CompletedAddNewMedIntent的Lambda代码,据推测是在多轮对话结束时触发的。

const CompletedAddNewMedIntent = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;

return request.type === 'IntentRequest'
  && request.intent.name === 'AddNewMedIntent'
  && request.dialogState === 'COMPLETED';
},
async handle(handlerInput) {
const filledSlots = handlerInput.requestEnvelope.request.intent.slots;
const slotValues = getSlotValues(filledSlots);

let outputSpeech = 'Great. Your new medicine has been added succesfully.';

try {

} catch (error) {
  outputSpeech = 'I am really sorry. I am still learning. Please try again later';
  console.log(`Intent: ${handlerInput.requestEnvelope.request.intent.name}: message: ${error.message}`);
}
return handlerInput.responseBuilder
  .speak(outputSpeech)
  .getResponse();
},
};

我将不胜感激。谢谢。

0 个答案:

没有答案