So I tried to dig into this library as it seems to make coding for Alexa using Java (and Scala) easier. I set up a build.sbt like this:
name := "hello-world"
version := "0.0.1-SNAPSHOT"
scalaVersion := "2.12.2"
libraryDependencies += "com.amazon.alexa" % "alexa-skills-kit" % "1.3.1"
libraryDependencies += "io.klerch" % "alexa-skills-kit-tellask-java" % "0.2.2"
I now created an utterances.yml
in resources/de-DE
like this:
SayWelcome:
Utterances:
- "Hallo. Das ist ein Test."
SayTest:
Utterances:
- "Das ist ein Test."
SaySorry:
Utterances:
- "Irgendwas ist schief gelaufen."
I created the speechlet handler:
@AlexaApplication(applicationIds = Array("amzn1.ask.skill.xxxxx"))
class HelloWorldSpeechletHandler extends AlexaRequestStreamHandler {
}
I created the error handler:
@AlexaLaunchListener
class HelloWorldLaunchHandler extends AlexaLaunchHandler {
def handleError(exception: AlexaRequestHandlerException): AlexaOutput = AlexaOutput.tell("SaySorry").build()
def handleRequest(input: AlexaInput): AlexaOutput = AlexaOutput.tell("SayWelcome").build()
}
And my test error handler (this time in Java to make sure Scala is not the cause for the problem):
@AlexaIntentListener(customIntents = "ThisIsATest")
public class ListThingsHandler implements AlexaIntentHandler {
@Override
public boolean verify(final AlexaInput input) {
return false;
}
@Override
public AlexaOutput handleRequest(final AlexaInput input) throws AlexaRequestHandlerException, AlexaStateException {
return AlexaOutput.tell("SayTest").build();
}
@Override
public AlexaOutput handleError(final AlexaRequestHandlerException exception) {
return AlexaOutput.tell("SaySorry").build();
}
}
In the interaction model builder (the new interactive one) I created a "ThisIsATest" intent and compiled the interaction model.
When I want to test my skill, I get this error in my log:
com.amazon.speech.speechlet.SpeechletException: Could not find a handler for speechlet request: java.io.IOException
java.io.IOException: com.amazon.speech.speechlet.SpeechletException: Could not find a handler for speechlet request
at io.klerch.alexa.tellask.model.wrapper.AlexaRequestStreamHandler.handleRequest(AlexaRequestStreamHandler.java:92)
Caused by: com.amazon.speech.speechlet.SpeechletException: Could not find a handler for speechlet request
at io.klerch.alexa.tellask.model.wrapper.AlexaSpeechlet.handleRequest(AlexaSpeechlet.java:105)
at io.klerch.alexa.tellask.model.wrapper.AlexaSpeechlet.onIntent(AlexaSpeechlet.java:90)
at com.amazon.speech.speechlet.SpeechletToSpeechletV2Adapter.onIntent(SpeechletToSpeechletV2Adapter.java:51)
at com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:218)
at com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)
at com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:91)
at io.klerch.alexa.tellask.model.wrapper.AlexaRequestStreamHandler.handleRequest(AlexaRequestStreamHandler.java:88)
I packed my Jar with the SBT assembly plugin which embeds all dependencies similar to the maven-shade-plugin.
What am I missing?