【问题标题】:Unable to debug "There was a problem with the requested skill's response"无法调试“请求的技能响应有问题”
【发布时间】:2018-09-12 13:39:55
【问题描述】:

背景:我正在研究一种抽认卡技能,该技能使 Alexa 能够询问有关编程语言的基本问题。用户可以在 Ruby、Python 或 JS 之间进行选择。

进展:

  • LaunchRequest 欢迎用户,然后询问他们的语言偏好
  • 用户响应,导致SetLanguageIntent触发
  • 然后向用户提出问题

但是,我无法通过SetLanguageIntent 而不遇到“请求的技能响应有问题”。

下面是对话:

从响应中可以看出,SetLanguageIntent 已正确激活,插槽 ruby 也正确匹配。

"request": {
        "type": "IntentRequest",
        "requestId": "amzn1.echo-api.request.743f750e-96d9-4ef9-aeba-e0aec2e45afb",
        "timestamp": "2018-09-12T13:35:25Z",
        "locale": "en-US",
        "intent": {
            "name": "SetMyLanguageIntent",
            "confirmationStatus": "NONE",
            "slots": {
                "language": {
                    "name": "language",
                    "value": "ruby",
                    "resolutions": {
                        "resolutionsPerAuthority": [
                            {
                                "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.ee34487d-d343-4deb-ab6c-193777c92aa8.languages",
                                "status": {
                                    "code": "ER_SUCCESS_MATCH"
                                },
                                "values": [
                                    {
                                        "value": {
                                            "name": "ruby",
                                            "id": "58e53d1324eef6265fdb97b08ed9aadf"
                                        }
                                    }
                                ]
                            }
                        ]
                    },
                    "confirmationStatus": "NONE"
                }
            }
        }

但是,此时总是出现错误消息“请求的技能响应有问题”。 CloudWatch Logs 上没有报告错误。

作为参考,这里是SetLanguageIntent 代码。如评论中所述,至少应该说测试“好的”。但是,它不会被执行。

'SetMyLanguageIntent': function() {

    this.response.speak('Okay'); //this should at least have been said

    this.attributes.flashcards.currentLanguage = this.event.request.intent.slots.languages.value;
    var currentLanguage = this.attributes.flashcards.currentLanguage

    this.response
      .speak('Okay, I will ask you some questions about ' +
        currentLanguage + '. Here is your first question. ' + 
        AskQuestion(this.attributes))
      .listen(AskQuestion(this.attributes));

    this.emit(':responseReady');
  },

非常感谢任何帮助!

编辑:使用插槽名称更新

【问题讨论】:

  • 能否记录下生成的响应 JSON 并分享一下
  • @CicilThomas 感谢您的评论。不幸的是,JSON 输出只是“空”
  • 这个函数是做什么的 AskQuestion(this.attributes))

标签: alexa alexa-skills-kit alexa-slot


【解决方案1】:

我发现您的代码有问题。这就是您可能遇到问题的原因。您正在尝试访问未定义的属性 this.event.request.intent.slots.languages.value。错误是词语言。应该是语言。

所以获取槽值的方法应该是: this.event.request.intent.slots.language.value

【讨论】:

  • 谢谢。我认为这是一个很好的见解,但是当从复数变为单数时并没有解决这个问题。我已经用我在 Alexa 控制台中使用的插槽更新了我的问题
  • Chmm,那么您必须尝试以另一种方式识别问题。 cloudwatch 日志中真的没有任何内容吗?另外,我建议您实施“SessionEndedRequest”,如果您没有这样做并记录错误,您会得到。另一件事。如果可以,请提供您在提出此请求时得到的响应错误。这可能会更清楚地说明什么是错误的。但基本上,尝试记录尽可能多的信息,确保函数按预期工作,并以正确的方式访问属性。
【解决方案2】:

我通过在回复中添加cardRenderer() 为自己解决了同样的问题。像这样:

this.response.speak("my text").cardRenderer("ttitle","some content","image");

在测试模拟器的设备日志中,我注意到卡片渲染器出现,说技能响应失败。所以我拍了一张,它奏效了。希望这也能为您解决问题!

【讨论】:

    猜你喜欢
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-27
    • 1970-01-01
    相关资源
    最近更新 更多