我正在创建一项技能,允许 Alexa 首先查询所有连接的设备(例如空调设备),并从服务返回一个列表(这些名称可由用户自定义)。我需要这些设备名称将它们存储为自定义插槽的值,以便能够向 Alexa 发出以下类型的命令:Alexa,告诉我 {deviceName} 的温度。
有什么想法或建议吗?
最佳答案
使用Alexa对话框,当dialogState != 'COMPLETED'时检查{deviceName}槽的值,如果它不在列表中,则通过正确的响应再次引出该槽。做这样的事情:
if (dialogState === 'STARTED') {
return handlerInput.responseBuilder
.addDelegateDirective()
.getResponse();
}
else if (dialogState !== 'COMPLETED') {
if (intent.slots.deviceName.value) {
if ( //check if the deviceName is not in the list ) {
return handlerInput.responseBuilder
.speak('Sorry, this device is not added in your list, say again...')
.addElicitSlotDirective(intent.slots.deviceName.name)
.getResponse();
}
else {
return handlerInput.responseBuilder
.addDelegateDirective()
.getResponse()
}
}
else {
//dialogState is 'COMPLETED'
//here you have the correct device name
}
关于amazon-web-services - 为 Alexa Skill 创建自定义和动态 Slot 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52862297/