Alexa Skill kit -Lambda function - Failed to check 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?

+6
source share
4 answers

This is an exception for me because I tried to run my lambda function without the proper JSON test event on the Actions tab. If you click on the Actions tab and then click on Configure Test Event, you must provide your input to the function in the form of JSON, which it can interpret. After a long search, I realized that you can get this JSON by going to the developer's console, where you created your skill, which has all your skill settings. On the left side, go to the "Test" tab, and then go to the "Service Simulator" section. There is a text box that says “Enter Utterance” in which you can enter a voice command into your function in the text, for example, “Alexa tell [yourApp] to say“ Hello. ”Click the“ Ask [yourApp] "button, and the Lambda request JSON will be generated in the left hand, and the output will be on the right, then just copy and paste this JSON on the left into the test event on your lambding console, and then you should be good.

+8
source

You have an invalid identifier in a supported application identifier. This identifier must be the identifier of the Alexa Skills app, 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 was from [id of the place here] But you really replace it all.

+8
source

I tried to create the address skill included in https://github.com/amzn/alexa-skills-kit-java , but I got the same type of error.

It turns out the problem was with DeviceAddressSpeechletRequestStreamHandler and instantiating Set<String> supportedApplicationIds in static block {}.

When I moved new HashSet<>(); In declaring class attributes, it began to work.

+1
source

I would put static code in the class you created that extends SpeechletLambda . This, I believe, is where the evaluation occurs and resolves before loading this class and executing the static code.

Alternatively, you can simply turn off validation. If someone knows your development environment well enough to call your personal lambda function, they probably know enough to fake your application id. Thus, there is not much security value to verify it. For example, to disable it, see here .

0
source

All Articles