alexa / alexa-skills-kit-sdk-for-java

The Alexa Skills Kit SDK for Java helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
http://developer.amazon.com/ask
Apache License 2.0
816 stars 746 forks source link

request for help #104

Closed MitchZhang closed 6 years ago

MitchZhang commented 6 years ago

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Expected Behavior

Alexa Simulator Console : play the audio that my webservice return ("http://other.web.ra01.sycdn.kuwo.cn/resource/n3/128/17/55/3616442357.mp3")

Current Behavior

Alexa Simulator Console : There was a problem with the requested skill's response,

Steps to Reproduce (for bugs)

Use Alexa Skill Console to test my skills,
-----------------------
1.input soft music to trigger the skill kit 
2.the my webservice renturn thr response
3. alexa consle get a error

Possible Solution

1.error mp3 url? this url is from china 
2.i return a wrong response ?

Context

Your Environment

Java Info

this is a request : { "version": "1.0", "session": { "new": false, "sessionId": "amzn1.echo-api.session.9fa1ae91-cc9c-4e5e-b223-f623e0886b9c", "application": { "applicationId": "amzn1.ask.skill.4c801746-e267-452c-b1ac-cbce1b814888" }, "user": { "userId": "amzn1.ask.account.AFTQZSUPH4CSJLSDVCHQTTM4NGRCVBLV6DAPCSROTHX5N2ETBDQYSQ4YDCKOS6BZ3E5DVGXJJVF2WQCCW7LNK2VEUIGNIQHDCGBNKG7WJCU6V65R6OUOA6UV4HC5Y52P4BGBPVK2SOMRSAAWHARLWB4DZX7L27CODZHVWZ74LWKGBA5J6TZQG6BC6FYUJB7SFKF3HUK53GNH3EQ" } }, "context": { "AudioPlayer": { "playerActivity": "IDLE" }, "Display": { "token": "" }, "System": { "application": { "applicationId": "amzn1.ask.skill.4c801746-e267-452c-b1ac-cbce1b814888" }, "user": { "userId": "amzn1.ask.account.AFTQZSUPH4CSJLSDVCHQTTM4NGRCVBLV6DAPCSROTHX5N2ETBDQYSQ4YDCKOS6BZ3E5DVGXJJVF2WQCCW7LNK2VEUIGNIQHDCGBNKG7WJCU6V65R6OUOA6UV4HC5Y52P4BGBPVK2SOMRSAAWHARLWB4DZX7L27CODZHVWZ74LWKGBA5J6TZQG6BC6FYUJB7SFKF3HUK53GNH3EQ" }, "device": { "deviceId": "amzn1.ask.device.AGUKPWMCR2QRKZEU7APTCMMVDPKSLPILMOGYP4GX47KP6WHKKCNCXZVSANXJORM2DCFOIIEX5SGMAA27RQDKM76AIN5LP546H5TPC4C7ALRNQ6YJUB2YVMIP656PCBBYNOSB7ZQBJKXCRBXSVUGOLGYEJYNA", "supportedInterfaces": { "AudioPlayer": {}, "Display": { "templateVersion": "1.0", "markupVersion": "1.0" } } }, "apiEndpoint": "https://api.amazonalexa.com", "apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjRjODAxNzQ2LWUyNjctNDUyYy1iMWFjLWNiY2UxYjgxNDg4OCIsImV4cCI6MTUyNDk5MDI4MiwiaWF0IjoxNTI0OTg2NjgyLCJuYmYiOjE1MjQ5ODY2ODIsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUdVS1BXTUNSMlFSS1pFVTdBUFRDTU1WRFBLU0xQSUxNT0dZUDRHWDQ3S1A2V0hLS0NOQ1haVlNBTlhKT1JNMkRDRk9JSUVYNVNHTUFBMjdSUURLTTc2QUlONUxQNTQ2SDVUUEM0QzdBTFJOUTZZSlVCMllWTUlQNjU2UENCQllOT1NCN1pRQkpLWENSQlhTVlVHT0xHWUVKWU5BIiwidXNlcklkIjoiYW16bjEuYXNrLmFjY291bnQuQUZUUVpTVVBINENTSkxTRFZDSFFUVE00TkdSQ1ZCTFY2REFQQ1NST1RIWDVOMkVUQkRRWVNRNFlEQ0tPUzZCWjNFNURWR1hKSlZGMldRQ0NXN0xOSzJWRVVJR05JUUhEQ0dCTktHN1dKQ1U2VjY1UjZPVU9BNlVWNEhDNVk1MlA0QkdCUFZLMlNPTVJTQUFXSEFSTFdCNERaWDdMMjdDT0RaSFZXWjc0TFdLR0JBNUo2VFpRRzZCQzZGWVVKQjdTRktGM0hVSzUzR05IM0VRIn19.PWLKuDJ65YlMglu-meYjsO-tiQ19Xpw2xsHbCTcIGUvIPVbzydeExpRNPNxO4PAyYACO8PHxkB8DvE5MIntHEEnmCQOKupDD4WMfU3KG2no9b94VZk7_lECJ0AswKD9dLBQE6_IRqHsoKFH2o6dugM3iR8Bsl8pXkzrSMbcijXxUZ6lAtnFxPSEyBExaoDM6L5s_xrHlBbiwagC__VRi4FJFGdl8wvXzbhIQ0Nw4QkejHl46z9VE17MqkJziMB3q1s-tPvcoMDc_53pcK1y6e53uxmUAu3iAS-FE21rGWDaZ_xIDGbB6nopQDbPNYASrb89VcaHtjf-vrsT7r6Jqgg" } }, "request": { "type": "IntentRequest", "requestId": "amzn1.echo-api.request.8239ed76-3004-43ee-b80d-c28950da9325", "timestamp": "2018-04-29T07:24:42Z", "locale": "en-US", "intent": { "name": "playmusic", "confirmationStatus": "NONE" } } }


this is response: { "body": { "version": "1.0", "response": { "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "REPLACE_ALL", "audioItem": { "stream": { "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjRjODAxNzQ2LWUyNjctNDUyYy1iMWFjLWNiY2UxYjgxNDg4OCIsImV4cCI6MTUyNDk5MDI4MiwiaWF0IjoxNTI0OTg2NjgyLCJuYmYiOjE1MjQ5ODY2ODIsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUdVS1BXTUNSMlFSS1pFVTdBUFRDTU1WRFBLU0xQSUxNT0dZUDRHWDQ3S1A2V0hLS0NOQ1haVlNBTlhKT1JNMkRDRk9JSUVYNVNHTUFBMjdSUURLTTc2QUlONUxQNTQ2SDVUUEM0QzdBTFJOUTZZSlVCMllWTUlQNjU2UENCQllOT1NCN1pRQkpLWENSQlhTVlVHT0xHWUVKWU5BIiwidXNlcklkIjoiYW16bjEuYXNrLmFjY291bnQuQUZUUVpTVVBINENTSkxTRFZDSFFUVE00TkdSQ1ZCTFY2REFQQ1NST1RIWDVOMkVUQkRRWVNRNFlEQ0tPUzZCWjNFNURWR1hKSlZGMldRQ0NXN0xOSzJWRVVJR05JUUhEQ0dCTktHN1dKQ1U2VjY1UjZPVU9BNlVWNEhDNVk1MlA0QkdCUFZLMlNPTVJTQUFXSEFSTFdCNERaWDdMMjdDT0RaSFZXWjc0TFdLR0JBNUo2VFpRRzZCQzZGWVVKQjdTRktGM0hVSzUzR05IM0VRIn19.PWLKuDJ65YlMglu-meYjsO-tiQ19Xpw2xsHbCTcIGUvIPVbzydeExpRNPNxO4PAyYACO8PHxkB8DvE5MIntHEEnmCQOKupDD4WMfU3KG2no9b94VZk7_lECJ0AswKD9dLBQE6_IRqHsoKFH2o6dugM3iR8Bsl8pXkzrSMbcijXxUZ6lAtnFxPSEyBExaoDM6L5s_xrHlBbiwagC__VRi4FJFGdl8wvXzbhIQ0Nw4QkejHl46z9VE17MqkJziMB3q1s-tPvcoMDc_53pcK1y6e53uxmUAu3iAS-FE21rGWDaZ_xIDGbB6nopQDbPNYASrb89VcaHtjf-vrsT7r6Jqgg", "url": "http://other.web.ra01.sycdn.kuwo.cn/resource/n3/128/17/55/3616442357.mp3", "offsetInMilliseconds": 0 } } } ], "shouldEndSession": true }, "userAgent": "ask-java/2.0.0 Java/1.8.0_141" } }

server code: String music = "http://other.web.ra01.sycdn.kuwo.cn/resource/n3/128/17/55/3616442357.mp3"; @Override public boolean canHandle(HandlerInput handlerInput) { return handlerInput.matches(intentName("playmusic")); }

@Override
public Optional<Response> handle(HandlerInput handlerInput) {
    String token2 = handlerInput.getRequestEnvelope().getContext().getSystem().getApiAccessToken();
    return handlerInput.getResponseBuilder().
            addAudioPlayerPlayDirective(PlayBehavior.REPLACE_ALL,0L,"",token2,music)
            .withShouldEndSession(true)
            .build();

}
brendanclement commented 6 years ago

Hey Mitch,

The audioplayer stream URL must be an HTTPS endpoint with a valid, trusted certificate: https://developer.amazon.com/docs/custom-skills/audioplayer-interface-reference.html#play-params It looks like the URL you're using to load the content is an HTTP endpoint.

One option could be to use S3 to host the file - that's what I use for hosting my in-skill content.

brendanclement commented 6 years ago

@MitchZhang it looks like you've been able to get your skill request/response working. Just want to check if with you if #102 has been resolved?

MitchZhang commented 6 years ago

@brendanclement I solved 102

MitchZhang commented 6 years ago

@brendanclement thank you. image

i upload a mp3 file in the S3 and get a https url , but still get the same problem. waht my cause this ? this is url: https://s3.amazonaws.com/mp3foralexa/test.mp3

this is what i response in the aws lambda :

String token2 = handlerInput.getRequestEnvelope().getContext().getSystem().getApiAccessToken(); return handlerInput.getResponseBuilder(). addAudioPlayerPlayDirective(PlayBehavior.REPLACE_ALL,0L,"",token2,music) .withShouldEndSession(true) .build();

MitchZhang commented 6 years ago

@brendanclement Is it because I set up a wrong token?

sungolivia commented 6 years ago

Hey Mitch,


{ "body": { "version": "1.0", "response": { "outputSpeech": { "type": "SSML", "ssml": "<speak>Now playing AWS Podcast</speak>" }, "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "REPLACE_ALL", "audioItem": { "stream": { "token": "AWS Podcast", "url": "https://d1le29qyzha1u4.cloudfront.net/AWS_Podcast_Episode_228.mp3", "offsetInMilliseconds": 4725 } } } ], "shouldEndSession": true }, "sessionAttributes": { "offset": 4725, "state": "Playback", "token": "AWS Podcast" }, "userAgent": "ask-java/2.0-SNAPSHOT Java/1.8.0_141" } }

This is what my response looks like when AudioPlayer.Play directive is called. For me I use persistence attributes to store my token which I use it to store the title of the music so I can fetch which song I left off where I exited the skill. Maybe you can try that as well.

It also helps since you are using AWS Lambda, check out Cloudwatch Log whenever you get "There was a problem with the requested skill's response" from Alexa. It helped me a lot debugging as well! If you still can't figure it out, paste any relevant log messages from Cloudwatch in here!

MitchZhang commented 6 years ago

@brendanclement Hey Brendan, Alexa Simulator say there is a unsupport directives,but why unsupport? image image

debug info: { "header": { "namespace": "SkillDebugger", "name": "CaptureDebuggingInfo", "messageId": "c821ab4e-ba57-40c8-b032-af646749cb4d" }, "payload": { "timestamp": "2018-05-03T01:55:27.447Z", "dialogRequestId": "309b7649-3743-4668-97d4-4f11e6744339", "skillRequestId": "amzn1.echo-api.request.4371c580-02df-4a8c-8b69-541b8e6489b5", "type": "SkillExecutionInfo", "content": { "invocationRequest": { "endpoint": "arn:aws:lambda:us-west-2:154922316202:function:playMusic", "body": { "version": "1.0", "session": { "new": false, "sessionId": "amzn1.echo-api.session.0b7823ac-9017-48b9-ad1e-6f36b4e25972", "application": { "applicationId": "amzn1.ask.skill.4c801746-e267-452c-b1ac-cbce1b814888" }, "user": { "userId": "amzn1.ask.account.AFTQZSUPH4CSJLSDVCHQTTM4NGRCVBLV6DAPCSROTHX5N2ETBDQYSQ4YDCKOS6BZ3E5DVGXJJVF2WQCCW7LNK2VEUIGNIQHDCGBNKG7WJCU6V65R6OUOA6UV4HC5Y52P4BGBPVK2SOMRSAAWHARLWB4DZX7L27CODZHVWZ74LWKGBA5J6TZQG6BC6FYUJB7SFKF3HUK53GNH3EQ" } }, "context": { "AudioPlayer": { "playerActivity": "IDLE" }, "Display": { "token": "" }, "System": { "application": { "applicationId": "amzn1.ask.skill.4c801746-e267-452c-b1ac-cbce1b814888" }, "user": { "userId": "amzn1.ask.account.AFTQZSUPH4CSJLSDVCHQTTM4NGRCVBLV6DAPCSROTHX5N2ETBDQYSQ4YDCKOS6BZ3E5DVGXJJVF2WQCCW7LNK2VEUIGNIQHDCGBNKG7WJCU6V65R6OUOA6UV4HC5Y52P4BGBPVK2SOMRSAAWHARLWB4DZX7L27CODZHVWZ74LWKGBA5J6TZQG6BC6FYUJB7SFKF3HUK53GNH3EQ" }, "device": { "deviceId": "amzn1.ask.device.AGUKPWMCR2QRKZEU7APTCMMVDPKSLPILMOGYP4GX47KP6WHKKCNCXZVSANXJORM2DCFOIIEX5SGMAA27RQDKM76AIN5LP546H5TPC4C7ALRNQ6YJUB2YVMIP656PCBBYNOSB7ZQBJKXCRBXSVUGOLGYEJYNA", "supportedInterfaces": { "AudioPlayer": {}, "Display": { "templateVersion": "1.0", "markupVersion": "1.0" } } }, "apiEndpoint": "https://api.amazonalexa.com", "apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjRjODAxNzQ2LWUyNjctNDUyYy1iMWFjLWNiY2UxYjgxNDg4OCIsImV4cCI6MTUyNTMxNjEyNywiaWF0IjoxNTI1MzEyNTI3LCJuYmYiOjE1MjUzMTI1MjcsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUdVS1BXTUNSMlFSS1pFVTdBUFRDTU1WRFBLU0xQSUxNT0dZUDRHWDQ3S1A2V0hLS0NOQ1haVlNBTlhKT1JNMkRDRk9JSUVYNVNHTUFBMjdSUURLTTc2QUlONUxQNTQ2SDVUUEM0QzdBTFJOUTZZSlVCMllWTUlQNjU2UENCQllOT1NCN1pRQkpLWENSQlhTVlVHT0xHWUVKWU5BIiwidXNlcklkIjoiYW16bjEuYXNrLmFjY291bnQuQUZUUVpTVVBINENTSkxTRFZDSFFUVE00TkdSQ1ZCTFY2REFQQ1NST1RIWDVOMkVUQkRRWVNRNFlEQ0tPUzZCWjNFNURWR1hKSlZGMldRQ0NXN0xOSzJWRVVJR05JUUhEQ0dCTktHN1dKQ1U2VjY1UjZPVU9BNlVWNEhDNVk1MlA0QkdCUFZLMlNPTVJTQUFXSEFSTFdCNERaWDdMMjdDT0RaSFZXWjc0TFdLR0JBNUo2VFpRRzZCQzZGWVVKQjdTRktGM0hVSzUzR05IM0VRIn19.Dy9xCX82NdWDdkKeODvYCNSxSyiyt1paLaobHAHg9-8RE2PS2ZGfCBBziveomiRCLBYAg5tzQJmHriI4Uvx-XLY7tLdTwfwgNS_UsbdTBEGiB1uqAeHRiec0bIhOOIA2pJXaxUU8p3iI_a_pMcQWCiv2KeITd1w-0XCeQS2jxCOOMZ8tGlDGJu0DFHIzkGS8HTaNC38aWgnK3AYQhoVDEN8KoM4fVKsEoFw_piw5yMJ6NKUUO48wcXKiVC6xGkzdHYRi_1XU2HKa3ikIOwhyhFJeLFc04PJe2lQb5RIX4V9I5gE6WiYsBtxpMgFMndB8nYaDwcr0xKAsCCPEyS4ODQ" } }, "request": { "type": "IntentRequest", "requestId": "amzn1.echo-api.request.4371c580-02df-4a8c-8b69-541b8e6489b5", "timestamp": "2018-05-03T01:55:27Z", "locale": "en-US", "intent": { "name": "playmusic", "confirmationStatus": "NONE" } } } }, "invocationResponse": { "body": { "version": "1.0", "response": { "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "REPLACE_ALL", "audioItem": { "stream": { "token": "AWS_Podcast_Episode_228", "url": "https://d1le29qyzha1u4.cloudfront.net/AWS_Podcast_Episode_228.mp3", "offsetInMilliseconds": 0 } } } ], "shouldEndSession": true }, "userAgent": "ask-java/2.0.0 Java/1.8.0_141" } }, "metrics": { "skillExecutionTimeInMilliseconds": 339 } } } }

brendanclement commented 6 years ago

The simulator does not support long form audio at this time. You'll need to use a device to test skill scenarios using audio player directives

MitchZhang commented 6 years ago

Thanks! An mobile phone App with Alexa Voice Service can test this long form audio ?

MitchZhang commented 6 years ago

@brendanclement Hi Brendan, I use beta test to test my skill , i use mobile phone witch installed Android App with Alexa Voice Service.than,i ask alexa with my Skill Invocation Name, but alexa did'n find the right skill kit that i created. I noticed that the skill will find the right skill kit only under the recently added tab,but the skill i created is under the All skills Tab. How to let the alexa find my skill kit ?

image image

MitchZhang commented 6 years ago

@brendanclement @sungolivia Thanks a lot for your help. I have solved the problems that i commented. 0v0 And I really hope that you can release a Chinese doc so that many Chinese developers can use it with less trouble. You may not know that there is a lot of troubles for Chinese developers to visit other country's website like American's .

sungolivia commented 6 years ago

Hey Mitch, we will bring it up with the team, closing this issue now since it's solved!