【发布时间】:2018-09-25 08:25:14
【问题描述】:
我正在使用 ASK SDK V2 for node.js 来开发 alexa 技能。根据文档,我们需要添加 Inprogress 以及 Completed 对话处理程序来实现对话委托。它工作正常,但响应以某种方式覆盖了我期望的响应。
Inprogress 意图处理程序:
const InProgressGetAuthors = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
handlerInput.requestEnvelope.request.intent.name === 'GetAuthors' &&
handlerInput.requestEnvelope.request.dialogState !== 'COMPLETED';
},
handle(handlerInput) {
const currentIntent = handlerInput.requestEnvelope.request.intent;
if (handlerInput.requestEnvelope.request.dialogState === "STARTED") {
return handlerInput.responseBuilder
.addDelegateDirective(currentIntent)
.getResponse();
} else if (handlerInput.requestEnvelope.request.dialogState !== 'COMPLETED') {
return handlerInput.responseBuilder
.addDelegateDirective()
.getResponse();
} else {
return currentIntent;
}
}
}
完成的意图处理程序:
const CompletedGetAuthors = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
handlerInput.requestEnvelope.request.intent.name === 'GetAuthors';
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak(author_propmt)
.reprompt(author_propmt)
.withStandardCard(
author_title,
author_copy,
author.imageUrl,
author.imageUrl
)
.withShouldEndSession(false)
.getResponse();
}
}
在完成的意图处理程序中,我在响应中发送卡片。它确实说出了文字,但没有显示卡片作为响应。
响应对象:
{
"body": {
"version": "1.0",
"response": {
"directives": [
{
"type": "Dialog.Delegate"
}
]
},
"sessionAttributes": {},
"userAgent": "ask-node/2.0.9 Node/v6.10.3"
}
}
如果您查看响应正文,则卡片丢失。我究竟做错了什么 ?谁能告诉我?
谢谢
【问题讨论】:
标签: node.js alexa alexa-skills-kit