question

nfang avatar image
nfang asked

Error with Audio Player Sample Project

I just went through the Audio Player Sample Project (https://github.com/alexa/skill-sample-nodejs-audio-player) and I am getting "The remote endpoint could not be called, or the response it returned was invalid." when trying to test the app I created through it.

When I go into the lambda function and try to go to the log through the error graph, I get this "There was an error loading Log Streams. Please try again by refreshing this page." I've been refreshing the page for about 20 minutes.

Can anyone provide any insight into this? Has anyone else tried this sample project and been successful?

alexa skills kitaudio
5 comments
10 |5000

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

Some more information. I'm getting this from testing the lambda function:

START RequestId: 713fb8b0-6a2e-11e6-a570-6fdab694ee53 Version: $LATEST
2016-08-24T19:10:38.734Z	713fb8b0-6a2e-11e6-a570-6fdab694ee53	TypeError: Cannot read property 'System' of undefined
    at exports.handler (/var/task/index.js:20:22)
END RequestId: 713fb8b0-6a2e-11e6-a570-6fdab694ee53
REPORT RequestId: 713fb8b0-6a2e-11e6-a570-6fdab694ee53	Duration: 159.11 ms	Billed Duration: 200 ms 	Memory Size: 128 MB	Max Memory Used: 23 MB	
Process exited before completing request

Looks like somehow event.context is undefined. This is the only place I found System used in index.js.

if (event.context.System.device.supportedInterfaces.AudioPlayer === undefined) {
        alexa.emit(':tell', 'Sorry, this skill is not supported on this device');
    }
    else {
        alexa.execute();
    }
0 Likes 0 ·

Another issue with the audio player sample project. I'm getting this error:

2016-08-24T19:27:37.692Z	d09419f8-6a30-11e6-b4df-cb43480e199d	The applicationIds don't match: amzn1.echo-sdk-ams.app.[unique-value-here] and amzn1.ask.skill.98c4b5ea-3f70-41d2-a54f-2a1cbe29a990
2016-08-24T19:27:37.694Z	d09419f8-6a30-11e6-b4df-cb43480e199d	{"errorMessage":"Invalid ApplicationId: amzn1.ask.skill.98c4b5ea-3f70-41d2-a54f-2a1cbe29a990"}

What is the difference between an amzn1.echo-sdk-ams.app.[...] id and a amz1.ask.skill.[...] id?

0 Likes 0 ·

The difference in prefixes is due to a recent update in the Alexa service. Older skills will use the amzn1.echo-sdk-ams.app prefix, the new skills will use amzn1.ask.skill

When setting the appId in the constants.js file, please ensure you copy the entire Application/Skill ID string from the Developer Portal. I'm assuming that if you've created a new skill in the Dev Portal, you'll see the newer prefix.

If you're using an older skill with the sample code, you might have the older type of prefix - so best to double-check.

0 Likes 0 ·

I am using the Application Id from the Skill Information section on the developer console. I see why the error is being thrown now. In Alexa.js in the example code from git hub, there are these lines of code:

    // Long-form audio enabled skills use event.context
    if (event.context) {
        requestAppId = event.context.System.application.applicationId;
        userId = event.context.System.user.userId;
    } else if (event.session) {
        requestAppId = event.session.application.applicationId;
        userId = event.session.user.userId;
    }

It then compares the applicationId that it is getting from event.context and comparing to what I have in the constants.js file.

    try {
        // Validate that this request originated from authorized source.
        if (handlerAppId && (requestAppId !== handlerAppId)) {
            console.log(`The applicationIds don\'t match: ${requestAppId} and ${handlerAppId}`);
            return context.fail('Invalid ApplicationId: ' + handlerAppId);
        }

So for some reason the query is getting the older skills prefix. Here is the error that is generated by this code:

START RequestId: e454caff-6bdf-11e6-897a-2bf7da17c70c Version: $LATEST
2016-08-26T22:53:23.911Z	e454caff-6bdf-11e6-897a-2bf7da17c70c	The applicationIds don't match: amzn1.echo-sdk-ams.app.[unique-value-here] and amzn1.ask.skill.98c4b5ea-3f70-41d2-a54f-2a1cbe29a990
2016-08-26T22:53:23.969Z	e454caff-6bdf-11e6-897a-2bf7da17c70c	{"errorMessage":"Invalid ApplicationId: amzn1.ask.skill.98c4b5ea-3f70-41d2-a54f-2a1cbe29a990"}
END RequestId: e454caff-6bdf-11e6-897a-2bf7da17c70c
REPORT RequestId: e454caff-6bdf-11e6-897a-2bf7da17c70c	Duration: 155.01 ms	Billed Duration: 200 ms 	Memory Size: 128 MB	Max Memory Used: 23 MB	

As you can see, requestAppId is the amzn1.echo-sdk-ams-app and handerlAppId is amzn1.ask.skill.[...]

This brings up another question. How important is it to keep this appID hidden? Since I posted it here, does that mean anyone can pose as my app?

0 Likes 0 ·
Show more comments
ekt1701 avatar image
ekt1701 answered

I am also getting this error, I entered my application ID, commented out the event.context, but left alexa.execute(); The node_modules/alexa-sdk is included in the zip.

I also went into the AWS Console for DynamoDB and created a table with the name LongFormAudioSample and enabled streams.

When I launch using my Echo, Alexa says "There is a problem with the requested skills response"

The applicationIds don't match: amzn1.echo-sdk-ams.app.[unique-value-here] and amzn1.ask.skill.

4 comments
10 |5000

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

Can you confirm that you're seeing an actual value for [unique-value-here] - or - are you seeing that literal string?

amzn1.echo-sdk-ams.app.[unique-value-here] is found in the AWS Lambda 'Alexa Start Session' event template test, and can be used to trigger your function from within the Lambda console.

If you're launching via your Echo, I'm curious how that string is reaching your Lambda skill backend.

0 Likes 0 ·

Hi James, I am seeing the literal string [unique-value-here] in the error message when using the Alexa Start Session test event in the AWS Lambda console. I entered the Skill App ID from the Developer Console to constants.js

In the Alexa App, I can see this message:

Request Identifier: amzn1.echo-api.request.6617676e-8600-4da0-944c-6f67180394fa 
The target Lambda application returned a failure response 

How can I find the string when I launch from my Echo?

0 Likes 0 ·

Ok, that makes sense.

You'll see that literal string when using the AWS Lambda 'Alexa Start Session' to test the uploaded code and so you'll need to replace it with the full Application/Skill ID from the Developer Portal.

Note: the Application/Skill ID prefix has recently changed and so you'll need to copy the whole string from the Developer Portal (not just the random sequence of characters that ID your skill).

We also need to update the event template tests in AWS Lambda to include an 'Alexa Audio Player Start Session' - because we need to accommodate for the new ASK Request structure inclusive of the System property.

1 Like 1 ·
Show more comments
newuser-a72dd11f-d896-477f-aed7-1516ae42c01d avatar image
newuser-a72dd11f-d896-477f-aed7-1516ae42c01d answered

I too am having the same problem. Also was having problems with the Alexa SDK not actually in the github documentation...

10 |5000

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

James Chivers avatar image
James Chivers answered

I'm sorry you hit these issues @nfang.

The Service Simulator in the Developer Portal does not provide the System object to the skill backend when supplying a test utterance and so should not be used with Audio Skills. Instead, please test with an Alexa-enabled device.

The second issue can be addressed by setting the appId variable in js/constants.js to your Application ID found in the Skill Information tab within the Developer Portal. We've since updated the file with an inline TODO for developers to update accordingly.

We plan on updating the README.md to call these two issues out and also to improve the sequence of steps when following the instructions to deploy the skill sample code.

Please let me know if you experience any further issues.

3 comments
10 |5000

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

Thank you James for the reply.

The error I'm getting about can't read property 'System" of undefined is coming from the lambda function, not the Service Simulator in the Developer Portal. I ended up commenting the text out quoted in the second comment and just left "alexa.execute();" and the error has gone away. It still needs to be addressed, but I seemed to have worked around that error.

For the Application Id, I went back and checked and I did update constants.js to have my Application Id from the skill information tab. That id is amzn1.ask.skill.[unique-value]. The error says that the application id should start with amzn1.echo-sdk-ams.app.[unique-value]. The third comment above was copied directly from the log output.

0 Likes 0 ·

I'm going to do some further testing tomorrow. Application / Skill ID's used to be prefixed with 'amzn1.echo-sdk-ams.app' but recently changed to the 'amzn1.ask.skill' prefix.

0 Likes 0 ·

@nfang Please be sure check the 'Audio Player - Yes', in the Developer Portal -> Skill Information tab for your skill.

This will ensure that your skill will receive the System property in the ASK Requests to your skill.

0 Likes 0 ·
James Chivers avatar image
James Chivers answered

If you're testing the sample code zip after uploading in the AWS Lambda console and hitting 'Save and Test' - using the 'Alexa Start Session' event template test - you'll see the reference to a lack of System property in the log output because that event template doesn't provide the required Audio Player properties (i.e. System) in the request.

10 |5000

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

nfang avatar image
nfang answered

The default test event is including the old style of the applicationId. Update the applicationId in the test event to your applicationId and this won't be an issue anymore. I also had to modify the code like this:

    alexa.execute();
    // if (context.System.device.supportedInterfaces.AudioPlayer === undefined) {
    //     alexa.emit(':tell', 'Sorry, this skill is not supported on this device');
    // }
    // else {
    //     alexa.execute();
    // }

Now the example works.

3 comments
10 |5000

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

Thanks for addressing this @nfang. I'm working from the same Audio Player Sample Project and hit some of the same with Lambda throwing System TypeErrors.

I also saw the appId errors you mentioned even though it was set it in constants.js— configuring my lambda test event did the trick.

I seem to be beyond those now thanks to your findings. However, now in Lambda I'm getting:

{
  "errorMessage": "Error fetching user state: ValidationException: The provided key element does not match the schema"
}

I'm not sure what's causing this error! In constants.js there's a peculiar empty string after the START_MODE key value for states.

All of my source is on GitHub here.

0 Likes 0 ·

@Drian I got the same error, it comes from the DynamoDB. When I got the audio project working, I could play the podcast, after I changed the audio list to hear something else, I got that error message.

So I went into the DynamoDB Console and deleted the table: LongFormAudioSample. After doing this, I was able to hear my audio. Hope this helps you.

0 Likes 0 ·

Thanks @ekt1701! I was able to get this going last week. I also had a bunch of JS I needed to edit in StateHandler.js to comply with how my app works.

Certification passed!

0 Likes 0 ·
EndaM avatar image
EndaM answered

Hi Guys, I've made the above modifications to the audio player sample on Github but I still getting the dreaded Lambda response "The remote endpoint could not be called, or the response it returned was invalid."

Any further ideas of what migh be wrong?

1 comment
10 |5000

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

Well here's what I got:

I went through most of the suggested items above and ran into some issues as well. If you haven't already, copy & paste the test Lambda request from your Alexa skill, and use it as your test event from the Lambda console. After fixing everything in the code, I was getting a timeout error. I changed the audio files, so I think this error was due to new audio files being used by the database.

I fixed this by deleting the "LongFormAudioSample" table that was created in DynamoDB.

That took a minute to complete, so I invoked the function a few times after it says the table was deleted. Then it worked!

0 Likes 0 ·