alexa-samples/skill-sample-nodejs-audio-player

'System' undefined error

Closed this issue · 5 comments

I followed all the instructions. When I ran the test for "LaunchRequest", I got the following error message:

TypeError: Cannot read property 'System' of undefined at exports.handler (/var/task/index.js:20:22)
Process exited before completing request

I use Windows 10 with Git Bash. I have also tried similar instructions in a Mac as well. I get the same error in both OS. Any help is much appreciated. Thanks.

That error is usually because the event format is different than what the code is expecting. When using Skills that have AudioPlayer enabled the event format changes and you may be using a test event in the older format. Here's a working event sample that will work with either version of event formats. Note that some of the items under "session" are now duplicated under "context".

{
  "session": {
    "new": true,
    "sessionId": "amzn1.echo-api.session.",
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account."
    },
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.test"
    }
  },
  "version": "1.0",
  "request": {
    "locale": "en-US",
    "timestamp": "2016-10-27T18:21:44Z",
    "type": "LaunchRequest",
    "requestId": "amzn1.echo-api.request."
  },
  "context": {
    "AudioPlayer": {
      "playerActivity": "IDLE"
    },
    "System": {
      "device": {
        "supportedInterfaces": {
          "AudioPlayer": {}
        }
      },
      "application": {
        "applicationId": "amzn1.echo-sdk-ams.app.test"
      },
      "user": {
        "userId": "amzn1.ask.account."
      }
    }
  }
}

Thanks Robert. The new event format you have given is working in Lambda function test.

Please note that earlier I copied the lambda request from amazon dev console for the skill. I am able to modify the lambda request in AWS console to test it. However, amazon dev console still forms the lambda request in older format. So, when the skill is triggered, it's going to make lambda request in the older format and fail.

Is there a way to configure test event format in developer console?

Following up on rammuthiah, I'm having the same issue. The test function you've posted works in Lambda, but when trying to give commands to echo it returns that there's an error with the response.

Is there a way to change the request it sends?

Pinging on this @rjamison @ZongwanAmz . Please let us know if there is a way to resolve this.

You can capture the correct event sent to your skill by using console.log in your skill code and then use the skill from a real device.
Examples of valid request captured that way are in the single-stream-sample project at https://github.com/alexa/skill-sample-nodejs-audio-player/tree/mainline/single-stream/lambda/test

To capture the full events and response sent to/from the skill, just modify the index.js function as this example https://github.com/alexa/skill-sample-nodejs-audio-player/blob/mainline/single-stream/lambda/src/index.js#L11

Logs are available in AWS Cloudwatch.