在 Alexa Skill 中处理重新提示时如何回退到错误 [英] How to fallback into error when reprompt is processed in Alexa Skill

查看:25
本文介绍了在 Alexa Skill 中处理重新提示时如何回退到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是开发 Alexa Skills 的新手.我正在为西班牙商店开发一项技能,所以我正在使用 es-ES 语音.我使用 Node.js ASK-SDK,但遇到了这个问题:

当我尝试与 reprompt 进行对话时,如果用户说胡言乱语,则不应触发我的任何话语,我希望进入错误处理程序,因为它是具有 canHandle == true 的处理程序,但实际结果是,Alexa 检测到该乱码并将其分类为正确的话语之一.我已经看到在美国你有 AMAZON.Fallback 来防止这个问题,但由于没有西班牙 SDK 有这个,我怎么能检测到这个?

我上传了一个演示项目来模拟这种行为

您可以尝试使用此工作流程:

  • 开始技能
  • 该技能返回第一"文本并保持聆听(因为有提示)
  • 你写的是第二个
  • 该技能返回第二个"文本并继续聆听并再次提示
  • 你说胡言乱语,例如d"或blah blah blah"
  • 您是根据明显随机的话语进行排序的.

这是blah blah blah"的 JSON 输入示例

<代码>{"版本": "1.0",会议": {新":假,"sessionId": "amzn1.echo-api.session.55b928a6-ecb2-4b55-857e-af6a76dee6fe",应用": {applicationId":amzn1.ask.skill.dd0b7ffd-b408-489a-ab5e-a7d7b8d05da3"},用户":{用户id": amzn1.ask.account.AFWPOWCRQULHUVKQTTX7JIS3O264CCHSUY4MPHCSJS4LKLQX45YARJ67LTGHPMS7RWUXVNYUTXT6JMT3DICTL5YZ7QHSLZ3QIHEKDP5YRPLCAEFXTD4BRY6WJIKC36UO3QU4F5X5BLFAGX6C3KN76MQJETO5PY6I65CVNOFBQLGNZ3P4YN4IOLYBCC7NDGAQ6LFAWMWTKT6DWQY"}},语境": {系统": {应用": {applicationId":amzn1.ask.skill.dd0b7ffd-b408-489a-ab5e-a7d7b8d05da3"},用户":{用户id": amzn1.ask.account.AFWPOWCRQULHUVKQTTX7JIS3O264CCHSUY4MPHCSJS4LKLQX45YAR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BPV0NSUVVMSFVWS1FUVFg3SklTM08yNjRDQ0hTVVk0TVBIQ1NKUzRMS0xRWDQ1WUFSSjY3TFRHSFBNUzdSV1VYVk5ZVVRYVDZKTVQzRElDVEw1WVo3UUhTTFozUUlIRUtEUDVZUlBMQ0FFRlhURDRCUlk2V0pJS0MzNlVPM1FVNEY1WDVCTEZBR1g2QzNLTjc2TVFKRVRPNVBZNkk2NUNWTk9GQlFMR05aM1A0WU40SU9MWUJDQzdOREdBUTZMRkFXTVdUS1Q2RFdRWSJ9fQ.H50aG2L-K_AH-vRQ4ueu6n8GY_3T14KVjJysJjpWaAJEMfVlkx6CNwnQjDQJZHd1GQ1UpqcT3AkpqGDg86Z2J50RDmRp5ScUqqMQu0ZjrCxG9hItwT02ca4wxEo_hFrMb5VTTgqSORbfgzmDHJMOVaWjb_zJAcAFCJrF3qxzYzEo-E2ptBdRb7xKY0y_3MisF302HTUiZC3uTiRvWxv3jMT0_vq9cXDoHOar_WDf7Q6afF4DrEj6naX_vRpHT-63nWug1TiKRaJY4sEEaTlX0BVDigJ7t1LuH76ULeDEpJrSNW3mQtrHqUCnFNRYe9_-RU-RF-NkMpotYE7glWNnZg"},视口":{经验":[{arcMinuteWidth":246,弧分高度":144,canRotate":假,canResize":假}],"shape": "矩形",像素宽度":1024,像素高度":600,dpi":160,当前像素宽度":1024,当前像素高度":600,触碰": [单身的"]}},要求": {"type": "IntentRequest","requestId": "amzn1.echo-api.request.fef2e2fc-b404-4729-85b4-e8ced71b6ecd","时间戳": "2018-11-16T08:17:34Z","locale": "es-ES",意图":{"name": "NumberTwoIntent",确认状态":无"}}}

我怎样才能防止这种情况发生?我希望输入错误,因为它是唯一一个可以为blah blah blah"话语返回 true 的处理程序,因此,告诉用户他们的语音存在错误,但由于它被分类为话语,它返回一些用户没有要求的信息.

谢谢

解决方案

在没有 FallbackIntent 但要尽可能广泛地使用您的模型确实可以处理的意图,并尝试识别人们可能想在域外询问您的技能的一些话语,并在一个单独的意图中捕获它们,最终将专门针对这些情况提供额外的答案.

所以总的来说,建议是:

  1. 为每个 Intent 提供 7 到 50 个话语,尝试提供具有代表性的话语样本,以确保您会发现同一意图的许多变体

  2. 确保您没有相同或相似的不同意图的话语(这将在模型选择意图时提供不可预测的结果)

  3. 如果你的意图有槽,验证它们并通知用户如果值不是你期望的.您可以在后端自己验证插槽,或者,最近刚刚添加,您也可以 通过对话管理验证槽.请注意,您可以使用 slot elicitation 如果您需要在验证失败后从用户那里获取有效的 slot 值p>

  4. 不要创建包含大量随机话语的意图,因为您可能会弄乱技能模型,为此目的创建槽也是如此.权衡是不值得的.如果您仍然想要解决方法,请尝试thisthis.

  5. 您可以创建一个意图来处理您可以预期的域外话语.例如,en-US 中的许多技能都具有可以处理 bla bla bla 的意图,正如人们通常所说的那样

  6. 不要依赖捕获所有处理程序(canHandle() 设置为始终返回true)以帮助您解决此问题.一些示例使用 UnhandledIntentHandler 并误导人们认为域外话语将由它处理,如果没有 FallbackIntent,则情况并非如此.同样,不要依赖通过 addErrorHandlers() 添加的 ErrorHandler,因为它只会在代码中存在实际错误时触发,而不是在 try/catch 中p>

一旦 Amazon.FallbackIntent 在您的语言环境中可用,请实施它并摆脱您自己的域外意图和/或解决方法(如果有)

I'm new to developing Alexa Skills. I'm working on a Skill for the Spanish store, so I'm using the es-ES voice. I use the Node.js ASK-SDK and I've come across this issue:

When I'm trying to develop a conversation with reprompt, if the user says gibberish, that shouldn't trigger any of my utterances, I expect to enter in the Error Handler, as it's the one with canHandle == true, but the actual result is that that gibberish is detected and sorted by Alexa as one of the correct utterances. I've seen that in en-US you have the AMAZON.Fallback to sort-of prevent this issue but as none of the Spanish SDK have this, how can I detect this?

I've upload a demo project to emulate this behaviour

You can try with this the workflow:

  • Start the Skill
  • The skill returns the "Number One" text and stays listening (as there's a reprompt)
  • You write number two
  • The skill returns the "Number Two" text and stays listening with another reprompt
  • You say gibberish, for example, "d" or "blah blah blah"
  • You are sorted on a apparently random utterance.

Here's an example of the JSON input for "blah blah blah"

{
"version": "1.0",
"session": {
    "new": false,
    "sessionId": "amzn1.echo-api.session.55b928a6-ecb2-4b55-857e-af6a76dee6fe",
    "application": {
        "applicationId": "amzn1.ask.skill.dd0b7ffd-b408-489a-ab5e-a7d7b8d05da3"
    },
    "user": {
        "userId": "amzn1.ask.account.AFWPOWCRQULHUVKQTTX7JIS3O264CCHSUY4MPHCSJS4LKLQX45YARJ67LTGHPMS7RWUXVNYUTXT6JMT3DICTL5YZ7QHSLZ3QIHEKDP5YRPLCAEFXTD4BRY6WJIKC36UO3QU4F5X5BLFAGX6C3KN76MQJETO5PY6I65CVNOFBQLGNZ3P4YN4IOLYBCC7NDGAQ6LFAWMWTKT6DWQY"
    }
},
"context": {
    "System": {
        "application": {
            "applicationId": "amzn1.ask.skill.dd0b7ffd-b408-489a-ab5e-a7d7b8d05da3"
        },
        "user": {
            "userId": "amzn1.ask.account.AFWPOWCRQULHUVKQTTX7JIS3O264CCHSUY4MPHCSJS4LKLQX45YARJ67LTGHPMS7RWUXVNYUTXT6JMT3DICTL5YZ7QHSLZ3QIHEKDP5YRPLCAEFXTD4BRY6WJIKC36UO3QU4F5X5BLFAGX6C3KN76MQJETO5PY6I65CVNOFBQLGNZ3P4YN4IOLYBCC7NDGAQ6LFAWMWTKT6DWQY"
        },
        "device": {
            "deviceId": "amzn1.ask.device.AETBPXRLKFDMVR23WFUFQ3HOFTGHQDISLOQAPWS4BDBD4FAGXUKW2P56RJ3G74C75HG63MS52UV7KFYJAENEVT6VIRZUEKWCQQHNGV3FMP6BM3A5JZCUXH2LRYDHLQLBH5ABDJ7EYRWUI5532NYEZLUCYIGMRZCM2WKQ3XG6NX5VZPOELTKUO",
            "supportedInterfaces": {}
        },
        "apiEndpoint": "https://api.eu.amazonalexa.com",
        "apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJB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WDf7Q6afF4DrEj6naX_vRpHT-63nWug1TiKRaJY4sEEaTlX0BVDigJ7t1LuH76ULeDEpJrSNW3mQtrHqUCnFNRYe9_-ru-rf-NkMpotYE7glWNnZg"
    },
    "Viewport": {
        "experiences": [
            {
                "arcMinuteWidth": 246,
                "arcMinuteHeight": 144,
                "canRotate": false,
                "canResize": false
            }
        ],
        "shape": "RECTANGLE",
        "pixelWidth": 1024,
        "pixelHeight": 600,
        "dpi": 160,
        "currentPixelWidth": 1024,
        "currentPixelHeight": 600,
        "touch": [
            "SINGLE"
        ]
    }
},
"request": {
    "type": "IntentRequest",
    "requestId": "amzn1.echo-api.request.fef2e2fc-b404-4729-85b4-e8ced71b6ecd",
    "timestamp": "2018-11-16T08:17:34Z",
    "locale": "es-ES",
    "intent": {
        "name": "NumberTwoIntent",
        "confirmationStatus": "NONE"
    }
}
}

How can I prevent this? I'd expect to enter the error, as it's the only one handler that could return true for "blah blah blah" utterance and so, tell the user there's been an error for their speech, but as it's being classified on a utterance, it returns some information the user hasn't asked for.

Thank you

解决方案

The recommended strategy for handling out-of-domain utterances in locales that have no FallbackIntent yet is to be as extensive as possible with the intents that your model can indeed handle and try to recognize some utterances people might want to ask your skill outside the domain and catch them in a separate intent that ultimately will provide extra answers specifically for those cases.

So overall the recommendation is to:

  1. Provide between 7 and 50 utterances per Intent, try to provide a representative sample of utterances to make sure you'll catch a lot of variations for the same intent

  2. Make sure you don't have utterances in different intents that are the same or similar (this will provide unpredictable results when the model selects an intent)

  3. If your intent has slots, validate them and notify the user if the values are not what you'd expect. You can validate slots yourself in the back-end or, just added recently, you can also validate slots via dialog management. Note that you can use slot elicitation if you need to get a valid slot value from the user after validation fails

  4. Do not create intents with a lot of random utterances since you risk messing up the model for the skill, as would creating slots for that purpose. The trade off is not worth it. If you still want a workaround try this or this.

  5. You can create an intent to handle out-of-domain utterances that you can kind of anticipate. For example a lot of skills in en-US have an intent that can handle bla bla bla as people tend to say it

  6. Do not rely on catch all handlers (canHandle() set to always return true) to help you with this. Some examples use an UnhandledIntentHandler and mislead people to think out-of-domain utterances will be handled by it which is not the case if there's no FallbackIntent. Similarly, do not rely on an ErrorHandler added via addErrorHandlers() as it will only trigger is there's an actual error in the code which is not inside a try/catch

As soon as Amazon.FallbackIntent becomes available in your locale implement it and get rid of your own out-domain intents and/or workarounds if you have them

这篇关于在 Alexa Skill 中处理重新提示时如何回退到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆