【问题标题】:How do I handle 'Yes'/'No' responses from the user in Custom Skill?如何处理自定义技能中用户的“是”/“否”响应?
【发布时间】:2017-07-09 06:33:57
【问题描述】:

我正在尝试构建一个 alexa 自定义技能。我正面临一个问题,我试图从用户那里获得是/否对技能向用户提出的问题的回答。

Alexa: Would you like to know the rules of the game?
User: <Can respond either Yes or No>

根据用户响应,我想执行特定操作。

这是我的意图架构:

{
    "intents": [
    {
        "intent": "AMAZON.StopIntent"
    },
    {
        "intent": "AMAZON.CancelIntent"
    },
    {
        "intent": "AMAZON.HelpIntent"
    },
    {
        "intent": "StartGame"
    },
    {
        "intent": "GetRules"
    }
  ]
}

这是我的示例话语:

StartGame Begin the game
StartGame Start the game

GetRules What are the rules
GetRules Get the rules
GetRules Tell me the rules
GetRules Tell me the rules again

技能向用户提出的问题如下:

Welcome to the game. Would you like me to tell you the rules?

每当我说“是”时,就会触发 StartGame 意图。 (“否”也是如此)。 Alexa 总是选择 Intent 作为 StartGame。调用“GetRules”意图的最佳方式是什么。我希望用户只说是/否,而不是说“获取规则”。

如果这个问题已经回答/需要更多信息,请告诉我。

【问题讨论】:

    标签: alexa alexa-skills-kit alexa-skill alexa-slot amazon-echo


    【解决方案1】:

    您需要使用 AMAZON.YesIntent 和 AMAZON.NoIntent。

    您可以在此处阅读有关它们的信息:。

    标准内置意图。 https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/standard-intents

    【讨论】:

    【解决方案2】:

    请在交互模型中添加以下代码。

    {
        "name": "AMAZON.NoIntent",
        "samples": []
    },
    {
        "name": "AMAZON.YesIntent",
        "samples": []
    }
    

    并在 lambda 中提供是/否的业务逻辑。

    'AMAZON.YesIntent': function () {
        //business code
    },
    'AMAZON.NoIntent': function () {
        //business code
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-02
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 2016-01-19
      • 2021-05-30
      相关资源
      最近更新 更多