Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ask-sdk-v1adapter: CreateStateHandler issues #438

Closed
eemmzz opened this issue Jul 30, 2018 · 3 comments · Fixed by #440
Closed

ask-sdk-v1adapter: CreateStateHandler issues #438

eemmzz opened this issue Jul 30, 2018 · 3 comments · Fixed by #440

Comments

@eemmzz
Copy link

eemmzz commented Jul 30, 2018

I'm submitting a...


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

Expected Behavior

Whilst using ask-sdk-v1adapter we would expect that setting this.handler.state would result in the correct handlers being called on a subsequent request.

Current Behavior

On the first request to our skill: everything works as expected
On the second request to our skill: from what we can see no handlers are being called - not even the Unhandled intent

We see this error in our bespoken proxy logs:

{"type":"INVALID_RESPONSE","message":"An exception occurred while dispatching the request to the skill."}

Context

We use state handlers so that our skill has multiple layers.

  1. Top layer - Navigation
  2. Inner layer - Games - Once the user says a game we recognise whilst in navigation we then register different intent handlers.

Example snippet:

const Alexa = require('ask-sdk-v1adapter');

const alexa = Alexa.handler(event, context, callback);
alexa.appId = 'AN_APP_ID';
alexa.registerHandlers(
  amazonEventHandlers,
  noStateHandlers,
  Alexa.CreateStateHandler('NAVIGATION_START', navigationStartIntentHandlers),
  Alexa.CreateStateHandler('NAVIGATION', navigationIntentHandlers),
  Alexa.CreateStateHandler('GAME', gameIntentHandlers),
);
alexa.execute();

Notes:

  • The above works in the alexa-sdk but not with ask-sdk-v1adapter.
  • The expected handler for NAVIGATION_START works on Launch.
  • We then set the state to NAVIGATION before we send our response. Once the next request is received no handlers seem to be called. Not even our no state handlers or the NAVIGATION_START handlers.

Noticed that logging out the result of the CreateStateHandler in ask-sdk-v1adapter it seems to keep re-adding the state name on each request:

{ LaunchRequest_NAVIGATION_START_NAVIGATION_START_NAVIGATION_START: [Function: launchRequest],
  Unhandled_NAVIGATION_START_NAVIGATION_START_NAVIGATION_START: [Function: launchRequest],
  SessionEndedRequest_NAVIGATION_START_NAVIGATION_START_NAVIGATION_START: [Function: sessionEndedRequest]
}

I think this may be the bug.

Steps to Reproduce (for bugs)

See above.

Your Environment

  • ASK SDK for Node.js used: "ask-sdk": "^2.0.7", "ask-sdk-v1adapter": "^2.0.7",
  • Operating System and version: I am on OSX 10.11.6. Also seen on OSX 10.12.6 (coworkers machine). Don't think the OS is relevant for this.

Node.js and NPM Info

  • Node.js version used for development: 8.11.1
  • NPM version used for development: 5.6.0
@tianrenz
Copy link
Contributor

Hi @eemmzz ,

I tested the createStateHandler with other skills and could NOT replicate the bug described above.

To help us identify the problem, could you provide more context on the issue:

  • error stacks thrown by the skill (if any)
  • the intent handler that's missed
  • is the error persistent on all type of request or just a particular set of them

Regards

@tianrenz
Copy link
Contributor

Hi @eemmzz ,

One more question, how are you logging the handler created from the CreateStateHandler. The keys seems to be incorrect as well. It should be the eventName + State. So, it should be LaunchRequestNAVIGATION_START not LaunchRequest_NAVIGATION_START

Regards

tianrenz pushed a commit that referenced this issue Jul 30, 2018
This commit contains the follow changes:
- Fix a bug where CreateStateHandler, when invoked multiple times
will repetitively append state string

fix #438
@eemmzz
Copy link
Author

eemmzz commented Jul 31, 2018

@tianrenz thank you, I can verify this fix seems to be working for us too. Cheers for the speedy turn around 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants