【问题标题】:Alexa how to implement intent confirmation?Alexa如何实现意图确认?
【发布时间】:2018-06-29 16:04:20
【问题描述】:

我在执行意图确认时遇到问题。文档真的很模糊。我目前正在使用 jovo 框架用 nodeJs 编写我的代码,这为我节省了大量时间。 这是我要如何确认用户请求的示例:
用户:Alexa,播放 NRJ 电台
Alexa:你想让我播放 NRJ 电台吗?
用户:是的
Alexa:我会播放 NRJ 收音机
Alexa 播放 NRJ 收音机
我已经在 Alexa 控制台中启用了意图确认,我认为这就足够了。但是,事实并非如此。我需要知道如何才能完成这项工作。谢谢。
我已多次阅读文档,但我不明白我应该如何使用 dialog.delegate 来实现我的目标,以及我是否应该以一种或另一种方式修改控制台中的 JSON 文件。
这真的很令人困惑,所以欢迎所有帮助。谢谢你:)

【问题讨论】:

    标签: javascript node.js alexa amazon-echo jovo-framework


    【解决方案1】:

    我们通常建议对此类事情使用状态。例如,您可以使用followUpState 在您的问题中添加状态PlayConfirmationState,然后在此状态下监听AMAZON.YesIntent

    这就是它在您的app.js 中的样子:

    app.setHandler({
        'LAUNCH': function() {
            this.followUpState('PlayConfirmationState').
                .ask('Do you want me to play NRJ radio?');
        },
    
        'PlayConfirmationState': {
            'AMAZON.YesIntent': function() {
                this.alexaSkill().audioPlayer().play('url', 'token')
                    .tell('I will play NRJ radio');
            },
    
            // Other intents in the state
    
        },
    
        // Other intents outside the state (stateless)
    
    });
    

    有关更多信息,请查看以下资源:

    【讨论】:

    • 谢谢@AhmedGhrib。介意将此作为“公认的答案”,以便其他人看到它也有效吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    • 2020-08-11
    • 2018-01-05
    • 1970-01-01
    • 2017-08-15
    相关资源
    最近更新 更多