vanderfox / alexa-skills-kit-java

SDK and example code for building voice-enabled skills for the Amazon Echo.
http://developer.amazon.com/ask
Apache License 2.0
3 stars 2 forks source link

issue with sdk handling playback commands after playback started #1

Closed rvanderwerf closed 7 years ago

rvanderwerf commented 7 years ago

Could not resolve type id 'PlaybackController.PlayCommandIssued' into a subtype of [simple type, class com.amazon.speech.speechlet.SpeechletRequest]: known type ids = [AudioPlayer.PlaybackFailed, AudioPlayer.PlaybackFinished, AudioPlayer.PlaybackNearlyFinished, AudioPlayer.PlaybackStarted, AudioPlayer.PlaybackStopped, IntentRequest, LaunchRequest, SessionEndedRequest, SessionStartedRequest, SpeechletRequest] at [Source: [B@6e15fe2; line: 1, column: 538](through reference chain: com.amazon.speech.json.SpeechletRequestEnvelope["request"]): com.fasterxml.jackson.databind.exc.InvalidTypeIdException com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'PlaybackController.PlayCommandIssued' into a subtype of [simple type, class com.amazon.speech.speechlet.SpeechletRequest]: known type ids = [AudioPlayer.PlaybackFailed, AudioPlayer.PlaybackFinished, AudioPlayer.PlaybackNearlyFinished, AudioPlayer.PlaybackStarted, AudioPlayer.PlaybackStopped, IntentRequest, LaunchRequest, SessionEndedRequest, SessionStartedRequest, SpeechletRequest] at [Source: [B@6e15fe2; line: 1, column: 538](through reference chain: com.amazon.speech.json.SpeechletRequestEnvelope["request"]) at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:42) at com.fasterxml.jackson.databind.DeserializationContext.unknownTypeIdException(DeserializationContext.java:1441) at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownTypeId(DeserializationContext.java:1169) at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleUnknownTypeId(TypeDeserializerBase.java:282) at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:156) at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:112) at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:97) at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:142) at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:488) at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeWithErrorWrapping(BeanDeserializer.java:511) at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:396) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1194) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:314) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2920) at com.amazon.speech.json.SpeechletRequestEnvelope.fromJson(SpeechletRequestEnvelope.java:148) at com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:61) at com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:92)

RommelTJ commented 7 years ago

Is this issue only with the MP3s? Is there an easy way to reproduce?

rvanderwerf commented 7 years ago

I can zip up my project but it's a groovy lambda but installs easy enough with gradle. Directives do work, playback starts then alexa calls back and I start getting those errors. I think that's because it fails on PlaybackController.PlayCommandIssued, that errors, then it sends System.Exception events after that. I'll post a link to the GH repo later today.

rvanderwerf commented 7 years ago

sorry for the delay github dns issues didn't help here. The project is here: https://github.com/rvanderwerf/alexa-groovy-podcast

I was testing it on a Amazon Tap, which has playback controls on the top of it. On the dot v2, sometimes the only way to make to make it stop is to unplug it lol ( I have more work to do on that skill!).

jtgrassie commented 7 years ago

You didn't merge my head commit on amazons head commit. That's why you're getting errors! I will not be contributing to your repository, only directly on amazons. Especially given how you dont seem ro know how to do merges correctly from PR's.

rvanderwerf commented 7 years ago

Nope, you are wrong, you did not implement them correctly. Audio responses require some kind of response of directives such as an empty list. I've fixed your code and merged it here. If you return void on the audio responses you will receive an Exception response from amazon. Oh and you didn't implement that either, which I've added support for so you can log the errors if you pass something invalid back from an audio type response. I did double check your branch on your repo you submitted the PR for. You don't have to be a good OS citizen or submit PRs here, that's certainly your choice. I've fixed it and moving on. I'll also be sure do put appropriate comments on your PR to their repo too. I do thank you for sharing your PR to them though, it was really most of the way there and mostly worked. I appreciate that you at least shared it - I was almost done with my version which was very similar, so I assumed yours was all the way. Overall your quality of it was quite good and I hope you have no hard feelings.

Here is an example Error amazon will send back if you send null responses on the audio requests(these were getting swallowed in your PR but with debug turned on I could see them in cloudwatch logs): { "version": "1.0", "context": { "System": { "application": { "applicationId": "amzn1.ask.skill.123456" }, "user": { "userId": "amzn1.ask.account.123456" }, "device": { "supportedInterfaces": { "AudioPlayer": {} } } } }, "request": { "type": "System.ExceptionEncountered", "requestId": "amzn1.echo-api.request.123456", "timestamp": "2016-10-25T04:22:56Z", "locale": "en-US", "error": { "type": "INVALID_RESPONSE", "message": "SpeechletResponse was null" }, "cause": { "requestId": "amzn1.echo-api.request.12345678" } } }

jtgrassie commented 7 years ago

You are simply wrong. You did not merge the tip of my audio branch. Anyway, glad you got all your merges working in the end.

jtgrassie commented 7 years ago

Further, you do not need to return anything from an audio request. The docs are pretty clear that if you do, you can only return certain audio playback messages. https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-audioplayer-interface-reference "Note: When responding to AudioPlayer requests, you can only respond with AudioPlayer directives. The response cannot include any of the standard properties such as outputSpeech. In addition, some requests limit the directives you can use, such as not allowing Play. Sending a response with unsupported properties causes an error. See the request types below for the limits on each request. ." The error you were getting is because you were sending an incorrect response to a audio player request. If you return nothing at all, they pass through fine.

rvanderwerf commented 7 years ago

So what I found the docs are ambiguous in this area. I found that a void/null response, triggers the System Exception encountered error call to the lambda fuction (see the sample I posted) after a bunch of live testing last night on a tap. However if I return some sort of response envelope, it seems to be happy(doesn't seen SystemError requests back). Even if it's just a empty list of directives. It's also funny maybe not documented well either is PlayBackStopped and The SystemError requests cannot have any directives returning, but if you pass null response envelopes it also triggers errors to come back to your skill (from alexa service). There could be some validation in the ResponseEnvelope class to check to see if any included directives are null like you said, or check to see in certain cases some directives are allowed and some are not depending on which ones (their docs do at least state that).

I was at AWS devdays yesterday and talked with some aws folks, apparently they are grappling with the # of github repos that github grades as 'poor health'. They also have an internal ticket process for changing things like docs and require things to go through legal which takes a very long time. A friend to works there was going to get in touch with the head SDK team to see what can be done at least for this sdk. I know the node one gets a lot more attention :(

jtgrassie commented 7 years ago

"I found that a void/null response" that's the problem. If you don't send anything back it works fine.

jtgrassie commented 7 years ago

You are simply wrong. You did not merge the tip of my audio branch. Anyway, glad you got all your merges working in the end.

On Oct 25, 2016 02:17, "Ryan Vanderwerf" notifications@github.com wrote:

Nope, you are wrong, you did not implement them correctly. Audio responses require some kind of response of directives such as an empty list. I've fixed your code and merged it here. If you return void on the audio responses you will receive an Exception response from amazon. Oh and you didn't implement that either, which I've added support for. I did double check your branch on your repo you submitted the PR for. You don't have to be a good OS citizen or submit PRs here, that's certainly your choice. I've fixed it and moving on. I'll also be sure do put appropriate comments on your PR to their repo too.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vanderfox/alexa-skills-kit-java/issues/1#issuecomment-255946540, or mute the thread https://github.com/notifications/unsubscribe-auth/AAzJTwQJW3dkMuamE7CnNMbTI3NMGu3eks5q3Z8WgaJpZM4Kbwp8 .

rvanderwerf commented 7 years ago

Correct. I feel like I am repeating myself for some reason or we're not communicating - Your original PR was sending null back and the return type for those methods was void. I added a return type of a list of directives for the methods that are allowed to, and a response envelop that wasn't getting added to fix it. In the case of the 2 items (SystemError and PlaybackStopped) I made the method return type in the skill void, but passed an empty envelope back instead of null like yours and now it's working without errors. I did many many live runs last night with debug mode and logging incoming request/responses to prove and test this.