question

coolcoder001 avatar image
coolcoder001 asked ·

Class does not implement an appropriate handler interface: com.amazon.ask.helloworld.handlers.HelloWorldIntentHandler

package com.amazon.ask.helloworld.handlers;
 import com.amazon.ask.dispatcher.request.handler.HandlerInput;
 import com.amazon.ask.dispatcher.request.handler.RequestHandler;
 import com.amazon.ask.model.Response;
 import com.amazon.ask.request.Predicates;
 import java.util.Optional;
 public class HelloWorldIntentHandler implements RequestHandler {
	 @Override
      public boolean canHandle(HandlerInput input) {
		 System.out.println("\n Hit the hello world intent handler\n");
         return input.matches(Predicates.intentName("HelloWorldIntent"));
      }
	 @Override
      public Optional handle(HandlerInput input) {
          String speechText = "Hello world";
          return input.getResponseBuilder()
                  .withSpeech(speechText)
                  .withSimpleCard("HelloWorld", speechText)
                  .build();
      }
 }

I am testing this class through Lambda function ,

here is my test JSON :

{
  "version": "1.0",
  "session": {
    "new": true,
    "sessionId": "amzn1.echo-api.session.8712bf4a-6239-4ea4-9b59-8ec6d468a46a",
    "application": {
      "applicationId": "amzn1.ask.skill.067f6b57-551a-4c91-9b01-1b3f135ab25a"
    },
    "user": {
      "userId": "amzn1.ask.account.AHOEMSSAODDWCDKQA6NFJNVJJKVMN2FN5XYI5RHZ7H7MKN2ACJ5ODSUZNBBDEEKAFX2T2OJYKIC5LPXKXZ4NMR2VZOTN3HHMKWCS5JTX6G7CGKLJUNSFHPYWI2DVCN7FYCDAK4MZO365RRW74LCPCSE74U5VSQN3F5LLP4LPPJBFIWQEDQBWKTGZTU5XG3DI66VEBOEJ67YSQJA"
    }
  },
  "context": {
    "System": {
      "application": {
        "applicationId": "amzn1.ask.skill.067f6b57-551a-4c91-9b01-1b3f135ab25a"
      },
      "user": {
        "userId": "amzn1.ask.account.AHOEMSSAODDWCDKQA6NFJNVJJKVMN2FN5XYI5RHZ7H7MKN2ACJ5ODSUZNBBDEEKAFX2T2OJYKIC5LPXKXZ4NMR2VZOTN3HHMKWCS5JTX6G7CGKLJUNSFHPYWI2DVCN7FYCDAK4MZO365RRW74LCPCSE74U5VSQN3F5LLP4LPPJBFIWQEDQBWKTGZTU5XG3DI66VEBOEJ67YSQJA"
      },
      "device": {
        "deviceId": "amzn1.ask.device.AFPWCGSWTSDH5WD2NC65F3D36Q2T3BOKWZR5RMOKC4HPBLGXU63NKDY7KQAKVET45HQ3ILJWVHB6K4PGBZ2E356DDQB7WLQJ3AOF35X2PC5GOPJMEB6PKMB5P47YKSKMTCJNACWSCMH6TX6LZLC5UWWZ4YAOPIL4P2HXRYI6QBA7WTEPP7QLY",
        "supportedInterfaces": {}
      },
      "apiEndpoint": "https://api.amazonalexa.com",
      "apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjA2N2Y2YjU3LTU1MWEtNGM5MS05YjAxLTFiM2YxMzVhYjI1YSIsImV4cCI6MTUzODE0NzIyNCwiaWF0IjoxNTM4MTQzNjI0LCJuYmYiOjE1MzgxNDM2MjQsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUZQV0NHU1dUU0RINVdEMk5DNjVGM0QzNlEyVDNCT0tXWlI1Uk1PS0M0SFBCTEdYVTYzTktEWTdLUUFLVkVUNDVIUTNJTEpXVkhCNks0UEdCWjJFMzU2RERRQjdXTFFKM0FPRjM1WDJQQzVHT1BKTUVCNlBLTUI1UDQ3WUtTS01UQ0pOQUNXU0NNSDZUWDZMWkxDNVVXV1o0WUFPUElMNFAySFhSWUk2UUJBN1dURVBQN1FMWSIsInVzZXJJZCI6ImFtem4xLmFzay5hY2NvdW50LkFIT0VNU1NBT0REV0NES1FBNk5GSk5WSkpLVk1OMkZONVhZSTVSSFo3SDdNS04yQUNKNU9EU1VaTkJCREVFS0FGWDJUMk9KWUtJQzVMUFhLWFo0Tk1SMlZaT1ROM0hITUtXQ1M1SlRYNkc3Q0dLTEpVTlNGSFBZV0kyRFZDTjdGWUNEQUs0TVpPMzY1UlJXNzRMQ1BDU0U3NFU1VlNRTjNGNUxMUDRMUFBKQkZJV1FFRFFCV0tUR1pUVTVYRzNESTY2VkVCT0VKNjdZU1FKQSJ9fQ.Ng1hQCykTbmw-5RkxUQ6auCZWwdEkavYC72oojTUDuPfHUQjwavlVZEgCEsXY5KwHlmMMBZAjcci_aV_6aaKrXwzTwBJeUS5KE8EcCwCsTcK2E8zerX3lnmQ5PVw8uNFHNyJ35k9NUuN8T57_bdlhXCHDmXIq3fjUCmpY-u_Nleg-4_9qnT9CubWNAtDkL7wm-TOZuWqDuZq2Y9UdQjXt6vVYc4r0kZTGHyLya3UTHuKShJTNEM00o7wgPHOyyXKXAHfJaUc_0iyyh9X3rCAGztZ4KXrPFFEffkUOGjNsJQHy241MWHG1oPeqw0eTNOqTREacUQoUJt4sZgqw4hz7Q"
    }
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "amzn1.echo-api.request.19396898-14e4-400b-b5e3-e2b81900c824",
    "timestamp": "2018-09-28T14:07:04Z",
    "locale": "en-IN",
    "intent": {
      "name": "HelloWorldIntent",
      "confirmationStatus": "NONE"
    }
  }
}

But , all I am getting is

Class does not implement an appropriate handler interface: com.amazon.ask.helloworld.handlers.HelloWorldIntentHandler

Can anyone please help me ?

alexa skills kitalexaalexa simulatoralexa skills challengealexa lists
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Albebach avatar image
Albebach answered ·

Sure, in addition to defining the class and providing the intent name in can_handle (which you have done), you also need to register this class with a SkillBuilder in order for Alexa to recognize it. Now, I'm a python guy, but I think the languages are similar enough that you can translate:

if you import StandardSkillBuilder and

sb = StandardSkillBuilder()

and then at the bottom of the code, add:

sb.add_request_handler(HelloWorldIntentHandler())

that should be enough for Alexa to recognize it.

1 comment
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @Albebach , thanks for your reply. I have solved the problem. I just repackaged the jar with all the necessary jars and then deployed. And voila , problem got resolved.

0 Likes 0 ·
coolcoder001 avatar image
coolcoder001 answered ·

I have solved the problem. I just repackaged the jar with all the necessary jars and then deployed. And voila , problem got resolved.

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.