Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alexa Skill kit -Lambda function - Could not validate SpeechletRequest (java)

I tried to create a HelloWorld Skill based on https://github.com/amzn/alexa-skills-kit-java but when I tested the lambda function it showed this error

{
  "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)"
    ]
  }
}

This is my Java file

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);
    }
}

What am i missing??

like image 607
Balaji Venkatesan Avatar asked Jun 10 '16 07:06

Balaji Venkatesan


2 Answers

You have the wrong ID in the supported application ID. That id needs to be the ID of the Alexa Skills application, which can be found on the Skill Information page. It should look something like this:

supportedApplicationIds.add("amzn1.ask.skill.c236d019-7d2a-5c96-a02f-ef8ab6f8e023");

I know the demo has is with [place id here] But you really replace the whole thing.

like image 102
mmaceachran Avatar answered Sep 19 '22 17:09

mmaceachran


For me I got this exception because I was trying to run my lambda function without a proper test event JSON under the Actions tab. If you click the 'Actions' tab and then click 'Configure Test Event' you are supposed give your function input in JSON form that it can interpret. After much looking I figured out that you can get this JSON by going to the developer console where you made your skill that has all your skill configurations. On the left hand side click on the 'Test' tab and then go to the section that says 'Service Simulator'. There is a text box that says 'Enter Utterance' where you can enter a voice command to your function in text e.g 'Alexa tell [yourApp] to say Hello'. Click the 'Ask [yourApp] ' button and a Lambda request JSON will be generated on the left hand box, with the output on the right. Then just copy and paste that JSON in the left into your test event in your lambda console and then you should be good.

like image 24
Dan Sagawaga Avatar answered Sep 21 '22 17:09

Dan Sagawaga