alexa-samples / skill-sample-nodejs-adventure-game

This tool provides an easy to use front-end that allows developers to instantly deploy code for your story, or use the generated code as a starting point for more complex projects.
Apache License 2.0
510 stars 218 forks source link

Created and uploaded, unable to test #3

Closed PantherTheCat closed 1 year ago

PantherTheCat commented 7 years ago

Left all code default, on amazon entered the instances and utterances, when testing the skill through the "Ask my skill" I encounter an error stating "The remote endpoint could not be called, or the response it returned was invalid."

Same result if I ask - Begin, Help, Launch, look, open etc.

{ "session": { "sessionId": "SessionId.0a49202c-5789-495c-b623-750fa27a9047", "application": { "applicationId": "amzn1.ask.skill.fd11987c-faca-4f13-b92a-1f533e4aca86" }, "attributes": {}, "user": { "userId": "amzn1.ask.account.AFP3ZWPOS2BGJR7OWJZ3DHPKMOMDHLY437I2OB3WH42YKPIHJ5IPM7H65B2VIYYR4TOSY6LIMP6EE2AD63VNKO436W2762S3KUHX6R2QPVM2UTI3QGBLHRNC56EDW4JTQ7YNH5Q7URKOB2EK723OY3F7GU5PK5NK7NGU7JXRL4ADSQP2T65NMYRLZ4RP6LOVIVUAYENM7QDTVAA" }, "new": true }, "request": { "type": "IntentRequest", "requestId": "EdwRequestId.6a19504a-f24c-4605-853d-218d64bfe754", "locale": "en-US", "timestamp": "2016-08-06T16:45:21Z", "intent": { "name": "BeginIntent", "slots": {} } }, "version": "1.0" }

rjamison commented 7 years ago

That usually indicates an issue inside the Lambda function. Could you check the logs in AWS under your Lambda function and see if you spot any errors?

screen shot 2016-08-06 at 10 12 23 am

If you don't spot anything there, it may also have been an issue with uploading the Function from the tool. That error would show up in the console where you started it:

screen shot 2016-08-06 at 10 15 38 am
irnglxy commented 7 years ago

I'm also having problems getting the files to upload. Maybe an error with my aws credentials? But I just can't figure out where I'm going wrong.

Any help would be greatly appreciated.

Ned

[17:22:58] Uploading Lambda function "MyAlexaSkillLambdaFunction"... /Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/request.js:30 throw err; ^

Error: The security token included in the request is invalid. at Request.callListeners (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/sequential_executor.js:107:43) at Request.emit (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/request.js:596:14) at Request.transition (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/request.js:21:10) at AcceptorStateMachine.runTo (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/state_machine.js:14:12) at /Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/request.js:37:9) at Request. (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/request.js:598:12) at Request.callListeners (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/sequential_executor.js:115:18) at Request.emit (/Users/Ned/interactive-adventure-game-tool/node_modules/gulp-awslambda/node_modules/aws-sdk/lib/sequential_executor.js:77:10)

rjamison commented 7 years ago

The error definitely indicates some issue with your keys. I receive the same error if I modify the "aws_access_key_id" value in the credentials file, so you could try double checking that value.

For posterity, tried these things to see what errors they'd produce:

  1. Removing the ~/.aws/credentials config entirely gave me: Error: Missing credentials in config
  2. Using an invalid access key gave me: Error: The security token included in the request is invalid.
  3. Using an invalid secret key gave me: Error: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
irnglxy commented 7 years ago

Hey Robert,

Thanks so much for getting back to me on this. I think you're totally right in that it's a problem with the keys, just trying to figure out a resolution - I'm a writer rather than a programer so please forgive my ignorance.

AWS seemed to want me to setup an IAM user rather for the account rather than use the root keys. So that's what I did and put in the two keys it gave me for the user. I'm not sure if there's anywhere else I should be linking to the account somewhere? To the best of my knowledge I've followed all the other steps correctly (although you never know...).

Thanks for you help! Excited to use the tool, think there are some really interesting possibilities there.

Ned

rjamison commented 7 years ago

No problem, you're exactly who we hope will give the tool a try :)

Setting up an IAM User shouldn't be an issue as long as you give the User permissions to access Lambda to update the code. Incorrect permissions would give an error like:

Error: User: arn:aws:iam::[REDACTED]:user/my_macbook is not authorized to perform: lambda:UpdateFunctionCode on resource: arn:aws:lambda:us-east-1:[REDACTED]:function:MyAlexaSkillLambdaFunction

I suggest you try creating new Security Credentials for the User account you've created (in AWS under "IAM" -> "Users" -> [YOUR USER ACCOUNT] -> "Security Credentials") and configuring those in case of a copy/paste error.

You could also try using the AWS command line tools, which provides a command that helps you configure the credentials. More details here: http://docs.aws.amazon.com/cli/latest/userguide/installing.html

irnglxy commented 7 years ago

I did try setting up new security credentials to no avail. Also installed the aws command line tool which seems to say I have correct (or at least some) credentials:

Neds-MacBook-Air:~ Ned$ aws configure AWS Access Key ID [_44A]]: AWS Secret Access Key [_E9a]]:

However I'm now being given an: Error: Missing credentials in config when trying to save.

Tried it on another machine with similar effect, only the security token error again.

Feel like I'm doing something fundamentally (and very possibly stupidly) wrong, just can't figure out where. Think I followed the instructions to the letter, the only additional step I had to take was before doing the npm install, I had to change directory with a cd to the interactive-adventuregame folder otherwise it gave me an error. Could it be that?

Thanks for your continued help!

PantherTheCat commented 7 years ago

So I checked and I show no Invocation of the Lambda function at all? Also I cannot view what is actually uploaded for whatever reason, as it is disabled from inline editing - Whilst I am glad you were able to help the other user - my issue is that i can upload, and it appears to have worked, but then the function isn't getting called? image

rjamison commented 7 years ago

Sorry for the delayed reply. Have been away for the last week.

@irnglxy sounds like you're doing all the right steps. Are you possibly using 'sudo' to run any of the steps? I've seen similar issues because the root user doesn't have credentials configured, even if your user account does.

@PantherTheCat sorry you're having trouble. You can download the file that was uploaded to lambda, the option is just a little hidden:

screen shot 2016-08-25 at 9 29 59 am

How are you invoking the skill when the function isn't called? If you're testing on a device, it could be that the "Alexa Skills" event source isn't configured for your Lambda, or that the configuration on https://developer.amazon.com has an issue.

irnglxy commented 7 years ago

Thanks Robert, I got around the problem by zipping the contents of the skills folder and manually uploading it to lambda. Would be easier to do it directly but just couldn't get to the bottom on the problem and this is working out fine.

Thanks!

PantherTheCat commented 7 years ago

I have tried to test from the web interface , and from the text interface on the skill page

Sent from my iPhone

On Aug 25, 2016, at 12:34 PM, Robert Jamison notifications@github.com wrote:

Sorry for the delayed reply. Have been away for the last week.

@irnglxy sounds like you're doing all the right steps. Are you possibly using 'sudo' to run any of the steps? I've seen similar issues because the root user doesn't have credentials configured, even if your user account does.

@PantherTheCat sorry you're having trouble. You can download the file that was uploaded to lambda, the option is just a little hidden:

How are you invoking the skill when the function isn't called? If you're testing on a device, it could be that the "Alexa Skills" event source isn't configured for your Lambda, or that the configuration on https://developer.amazon.com has an issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

winglmui commented 7 years ago

I am having a similar problem as @PantherTheCat. I got this as an error when I tested via the skill page text interface:

{ "errorMessage": "Cannot find module 'index'", "errorType": "Error", "stackTrace": [ "Module.require (module.js:353:17)", "require (internal/module.js:12:17)" ] }

PaulCutsinger commented 7 years ago

When you zip, be sure that your index.js is at the root of the zip. Don't include the containing folder of index.js, or you'll see this error

winglmui commented 7 years ago

@PaulCutsinger The tool itself did the zipping and uploading for me. So I guess I should manually zip all the files? Alternatively, is there a place where the tool puts the zip it makes so I can see what went wrong in there?

Thanks!

tedbarnett commented 7 years ago

@PaulCutsinger I was having the same issue (on Windows 10) as @winglmui, but followed the helpful suggestion of @irnglxy and got it working. I found that I had to go inside the "/src/skill" folder and zip up all the files there (index.js, AlexaSkill.js, polyfills.js, and the folders handlers, models, and tests). I uploaded that zipped file to Lambda (the old-fashioned Alexa Skill upload method). It then worked perfectly.

FYI: I noticed a file called "dist.zip" already in my skill folder that I presume was created by the Adventure Maker tool. It does not seem to have been created at the right directory "level": it contains the folder "src", which contains skill, which contains index.js. Perhaps something amiss in the zipping-and-uploaded process under Windows?

thomseninteractive commented 7 years ago

I have replicated the problem and workaround @tedbarnett described on Windows. Where can we look to correct the path of the zipped file on Windows? I was happy to get everything working by manually uploading the files - but knowing that upload button is there but not usable----help!!

I believe that it could be fixed with someone smarter than me taking a look at: gulp-tasks/_upload.js That's the one!

MureedSultan commented 7 years ago

Replacing

path.dirname = path.dirname.replace('src/skill', '' )

with

path.dirname = path.dirname.replace('src\\skill', '' )

fixes the problem on Windows. Might break on other OS though.

thomseninteractive commented 7 years ago

@MureedSultan the updated button worked on Windows 10! I hope in the near future a method is revealed for automatically updating the utterances and intents.

hasimam commented 7 years ago

would you please tell us how to setup the tool on windows operated machien ?

msymonds commented 6 years ago

If anybody was using the tool to directly upload the code but having the same issue that @winglmui and @PantherTheCat were having, where testing the module produced the "Cannot find module 'index'" error described above, or as described by the CloudWatch log:

Unable to import module 'index': Error at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19)

You can fix this by going to the configuration tab in the AWS Lambda console and updating the handler field from "index.handler" to "/src/skill/index.handler".