Alexa Skill kit -Lambda函数 - 无法验证SpeechletRequest(java)

Bal*_*san 8 alexa alexa-skill alexa-skills-kit alexa-voice-service

我尝试基于https://github.com/amzn/alexa-skills-kit-java创建一个HelloWorld技能但是当我测试lambda函数时它显示了这个错误

{
  "errorMessage":"com.amazon.speech.speechlet.SpeechletRequestHandlerException: Could not validate SpeechletRequest null using verifier ApplicationIdSpeechletRequestVerifier, rejecting request",

  "errorType": "java.lang.RuntimeException",

  "stackTrace": [    "com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:101)",
 "helloworld.HelloWorldSpeechletRequestStreamHandler.handleRequest(HelloWorldSpeechletRequestStreamHandler.java:43)"

 ],

  "cause": {

    "errorMessage": "Could not validate SpeechletRequest null using 
verifier ApplicationIdSpeechletRequestVerifier, rejecting request",
    "errorType": "com.amazon.speech.speechlet.SpeechletRequestHandlerException",

    "stackTrace": [
      "com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:73)",
      "com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:98)",
      "helloworld.HelloWorldSpeechletRequestStreamHandler.handleRequest(HelloWorldSpeechletRequestStreamHandler.java:43)"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的Java文件

public final class HelloWorldSpeechletRequestStreamHandler extends SpeechletRequestStreamHandler {
    private static final Set<String> supportedApplicationIds = new HashSet<String>();
    static {
        /*
         * This Id can be found on https://developer.amazon.com/edw/home.html#/ "Edit" the relevant
         * Alexa Skill and put the relevant Application Ids in this Set.
         */
        supportedApplicationIds.add("amzn1.echo-sdk-ams.app.[amzn1.echo-sdk-ams.app.56bcdaf9-97fc-47f9-9918-43cb6a90d9f5]");
    }


    public HelloWorldSpeechletRequestStreamHandler() {
        super(new HelloWorldSpeechlet(), supportedApplicationIds);
    }
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

mma*_*ran 10

您在支持的应用程序ID中具有错误的ID.该id必须是Alexa Skills应用程序的ID,可以在Skill Information页面上找到.它应该看起来像这样:

supportedApplicationIds.add("amzn1.ask.skill.c236d019-7d2a-5c96-a02f-ef8ab6f8e023");
Run Code Online (Sandbox Code Playgroud)

我知道演示有[在这里的地方ID]但你真的取代了整个事情.


小智 8

对我来说,我得到了这个例外,因为我试图在Actions选项卡下运行我的lambda函数而没有正确的测试事件JSON.如果单击"操作"选项卡,然后单击"配置测试事件",则应该以JSON形式提供可以解释的函数输入.经过深思熟虑后,我发现你可以通过开发人员控制台获得这个JSON,你可以在那里掌握所有技能配置.在左侧单击"测试"选项卡,然后转到"服务模拟器"部分.有一个文本框显示"Enter Utterance",您可以在文本中输入语音命令,例如'Alexa tell [yourApp] to say Hello'.单击"询问[yourApp]"按钮,左侧框将生成一个Lambda请求JSON,右侧输出.然后只需将左侧的JSON复制并粘贴到lambda控制台中的测试事件中,然后就可以了.