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

Reset current state #159

Closed
ysak-y opened this Issue Jul 25, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@ysak-y
Copy link

ysak-y commented Jul 25, 2017

Overview

I use DynamoDB in this sdk. This saves current state to DynamoDB if I set state to this.handler.state.
But I can't find how reset state because when I set empty string('') to this.handler.state, sdk ignore to update.
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/blob/master/lib/response.js#L206
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/blob/master/lib/response.js#L225

What should I do if I want to reset current state. If there are no ways, I'll implement.

@benedekh

This comment has been minimized.

Copy link

benedekh commented Jul 26, 2017

Empty string is a falsy (evaluates to false) value in JS. See https://dorey.github.io/JavaScript-Equality-Table/

@ysak-y

This comment has been minimized.

Copy link
Author

ysak-y commented Jul 26, 2017

Yes, I know, so how do I reset state ?
Delete STATE key & value in DynamoDB directory?

@valentinkostadinov

This comment has been minimized.

Copy link

valentinkostadinov commented Aug 23, 2017

I'm having the exact same problem. Any updates on this?

How do I reset state? This is especially bothersome since the official README makes an example out of it:

var guessModeHandlers = Alexa.CreateStateHandler(states.GUESSMODE, {

    'NewSession': function () {
        this.handler.state = '';
        this.emitWithState('NewSession'); // Equivalent to the Start Mode NewSession handler
    },

And under Tips, it says:

If the target state is "", then this.emit("TargetHandlerName") should be called.

@ysak-y

This comment has been minimized.

Copy link
Author

ysak-y commented Aug 29, 2017

If the target state is "", then this.emit("TargetHandlerName") should be called.

This sample is correct if you call TargetHandlerName with no STATE. But after response, state will back to current state(not empty state).

Now we don't have a way to reset current state.

@allthepies

This comment has been minimized.

Copy link

allthepies commented Oct 28, 2017

I've having the same problem, an attempt to reset state to "empty" is ignored by the ASK.
The following workaround does work for me:

  this.handler.state = constants.states.START_MODE;
  this.attributes.STATE = null;

where constants.states is
states: {
START_MODE: '',
DETAIL_DECISION_MODE: '_DETAIL_DECISION_MODE'
}

I have found that I need both of the "reset" code lines, the first used the documented approach and the second sets the state entry ("STATE") in the session attributes to NULL directly. This works for me.

@tianrenz

This comment has been minimized.

Copy link
Contributor

tianrenz commented Nov 9, 2017

issue closed.
future discussion please refer to issue #69

@tianrenz tianrenz closed this Nov 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment