amazon-web-services - 为 Alexa Skill 创建自定义和动态 Slot 值

标签 amazon-web-services iot alexa-skills-kit

我正在创建一项技能,允许 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/

相关文章:

java - ISO C++ 禁止声明没有类型的 'init' [-fpermissive]

node.js - 我收到 "error message: Process exited before completing request"

javascript - Intent 的 Alexa 调用名称不起作用

alexa - 在 Alexa 中获取相对时间

amazon-web-services - 无法在 CodeBuild 中运行 bash 脚本

ios - 如何在 iOS 中连接 amazon rds mysql

amazon-web-services - 如何将电子邮件从 godaddy 转移到 AWS

c# - VS2019 中的 Azure IoT 解决方案仅适用于系统重启后的首次运行

events - 物联网流数据处理的最佳实践

amazon-web-services - awscli s3 : upload via stdin