alexa - addDelegateDirective 和意图的问题
问题描述
所以我在构建我的 alexa 技能时遇到了问题,我需要将 Intent 链接到我的 Launchrequest,它适用于此
return handlerInput.responseBuilder
.addDelegateDirective({
name: 'UserLogin',
confirmationStatus: 'NONE',
slots: {}
})
.speak("You need to login!")
.withShouldEndSession(false)
.getResponse();
但是在我的链式意图中,我需要填充 2 个插槽,但是 alexa 只要求一个意图两次,然后什么也没有,它不要求第二个意图?
这是我在 lambda 中的意图
const LoginUserIntent= {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest' &&
request.intent.name === 'UserLogin' &&
request.dialogState !== 'COMPLETED';
},
handle(handlerInput) {
return handlerInput.responseBuilder
.getResponse()
},
}
知道我怎样才能完成这项工作吗?
解决方案
我知道这已经很长时间了,但在这种情况下,发生的事情是您必须在 addDelegateDirective() 的插槽参数中设置所有插槽。
这是一个示例代码:
.addDelegateDirective({
name: 'UserLogin',
confirmationStatus: 'NONE',
slots: {
slot01: {
name: 'slot01',
confirmationStatus: 'NONE',
type: 'AMAZON.NUMBER',
source: 'USER'
}
}
})
您还必须设置插槽类型。周围有很多样本缺少这个属性,至少在我的情况下,它不起作用。
如果有帮助,请告诉我。
推荐阅读
- python - 如何通过 pytorch 加载预训练模型?(mm时尚)
- xml - 将 SOAP XML 行转换为 PowerShell 中的列
- swift - 如何构建可以在 UiactivityController 中显示的功能?
- bluetooth-lowenergy - BLE 128b 服务 UUID
- docker - 在dockerfile中使用带有tomcat:9.0.45-jdk8-adoptopenjdk-hotspot的docker镜像时如何将shell文件作为入口点运行?
- google-apps-script - 如何将数据记录到指定列的最后一行,而不是所有列的最后一行?
- java - 加载共享库 libstdc++.so.6 时出错:没有这样的文件或目录(需要)
- python - Gekko 最优控制。我不能将一个值保持在其范围内
- angular - 时刻正在将无效的日期字符串转换为日期
- google-cloud-platform - 从 python 获取调度程序作业的状态