【问题标题】:Alexa - catchallAlexa - 包罗万象
【发布时间】:2018-10-01 13:16:50
【问题描述】:

我有一个插入后端和 DialogFlow/ApiAI 的聊天机器人。 我正在尝试在 Alexa 中设置一项技能,以便我可以捕捉到我的技能所说的所有内容,然后将其转发到我的后端,以便我可以使用我现有的基础设施和 convo 设计。

我一直在努力与 Alexa 建立一个捕获所有内容并转发它的意图。 据我了解,您应该使用 AMAZON.SearchQuery,但是当我尝试设置意图时出现以下错误:

构建失败 意图“CATCH_ALL”中的示例话语“CATCH_ALL {any}”必须包含载体短语。具有短语类型的示例意图话语不能仅包含槽。错误代码:MissingCarrierPhraseWithPhraseSlot -

有人知道怎么做吗?我也尝试使用 AMAZON.Literal,但它似乎已被弃用,并且当我使用它时我无法建立技能。 我有点卡住了。如果有人有解决方案那就太好了...

谢谢。

【问题讨论】:

    标签: alexa alexa-skills-kit dialogflow-es api-ai


    【解决方案1】:

    我终于通过这样做:

        {
            "interactionModel": {
                "languageModel": {
                    "invocationName": "test",
                   "intents": [
                    {
                    "name": "AMAZON.CancelIntent",
                        "samples": []
                    },
                    {
                        "name": "AMAZON.HelpIntent",
                        "samples": []
                    },
                    {
                        "name": "AMAZON.StopIntent",
                        "samples": []
                    },
                    {
                        "name": "CATCHALL",
                        "slots": [
                            {
                                "name": "any",
                                "type": "AMAZON.LITERAL"
                            }
                        ],
                            "samples": [
                                "{hey|any}",
                                "{hey hey|any}",
                               "{hey hey hey|any}",
                                "{hey hey hey hey|any}",
                                "{hey hey hey hey hey|any}"
                            ]
                        }
                    ],
                    "types": []
                }
            }
        }
    

    意图 CATCHALL 的样本指示您要捕获的单词数。所以,我会抓住 1 到这 5 个单词之间的任何句子。

    不过,我不确定当我提交应用程序时这是否会成为问题。

    请注意,除英语(美国)以外的任何语言都不支持 AMAZON.LITERAL,因此这不是我的解决方案,因为它是法语和英语聊天机器人。所以我又回到了起点……

    编辑:这是没有 LITERAL 的解决方案:

    { "interactionModel": { "languageModel": { "invocationName": "mon invocation", "intents": [ { "name": "AMAZON.CancelIntent", "samples": [] }, { "name": "AMAZON.HelpIntent", "samples": [ "que puis-je faire" ] }, { "name": "AMAZON.StopIntent", "samples": [ "je veux quitter" ] }, { "name": "CATCH_ALL", "slots": [ { "name": "any", "type": "ANYTHING" } ], "samples": [ "{any}" ] } ], "types": [ { "name": "ANYTHING", "values": [ { "name": { "value": "hey" } }, { "name": { "value": "hey hey" } }, { "name": { "value": "hey hey hey" } }, { "name": { "value": "hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey hey hey hey hey hey" } }, { "name": { "value": "hey hey hey hey hey hey hey hey hey hey hey hey" } } ] } ] } } }

    【讨论】:

    • 我想实现和你一样的东西,但我不明白所有这些嘿嘿。它最终会抓住嘿句子....
    • 好吧,因为没有其他匹配模式,“嘿嘿”总是会找到最接近的。最后,我用随机单词生成了 x 个句子,它实现了相同的目标,但阅读时更容易理解。关键是句子总是比前一个多一个词。否则,它不会捕捉到整个句子。
    【解决方案2】:

    您可以将 AMAZON.SearchQuery 替换为 AMAZON.Person。通常,AMAZON.SearchQuery 需要一个短语和插槽。使用 AMAZON.Person 不需要短语和插槽。它会接受您传递给 Intent 的任何值。

                   {
                    "name": "CATCH_ALL",
                    "slots": [
                        {
                            "name": "any",
                            "type": "AMAZON.Person"
                        }
                    ],
                    "samples": [
                        "{any}"                      
                    ]
                }
    

    【讨论】:

    • "AMAZON.SearchQuery 需要一个短语和插槽" - 这是关键!
    【解决方案3】:

    很遗憾,目前没有解决方案。 Alexa 不支持以您希望的方式获取所有文本的方式。

    【讨论】:

    • 找到了解决方案,我用解决方案编辑了响应
    • @JulienCoo 是的,但这不是一个“包罗万象”的解决方案。
    【解决方案4】:

    您可以使用一些随机单词创建自定义插槽。

    {
        "interactionModel": {
            "languageModel": {
                "invocationName": "demo",
                "intents": [
                    {
                        "name": "AMAZON.CancelIntent",
                        "samples": []
                    },
                    {
                        "name": "AMAZON.HelpIntent",
                        "samples": []
                    },
                    {
                        "name": "AMAZON.StopIntent",
                        "samples": []
                    },
                    {
                        "name": "EveryThingIntent",
                        "slots": [
                            {
                                "name": "EveryThingSlot",
                                "type": "BAG_OF_WORDS"
                            }
                        ],
                        "samples": [
                            "{EveryThingSlot} "
                        ]
                    }
                ],
                "types": [
                    {
                        "name": "BAG_OF_WORDS",
                        "values": [
                            {
                                "name": {
                                    "value": "Hello World"
                                }
                            }
                        ]
                    }
                ]
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-23
      • 2011-02-12
      • 2011-09-09
      • 2014-04-27
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      相关资源
      最近更新 更多