Earlier I ran into the issue of Alexa not changing the state back to the blank state, and found out that there is a bug in doing that. To avoid this issue altogether, I decided that I wanted to force my skill to always begin with START_MODE
.
I used this as my reference, where they set the state of the skill by doing alexa.state = constants.states.START
before alexa.execute()
at Line 55. However, when I do the same in my code, it does not work.
Below is what my skill currently looks like:
exports.newSessionHandler = {
LaunchRequest () {
this.hander.state = states.START;
// Do something
}
};
exports.stateHandler = Alexa.CreateStateHandler(states.START, {
LaunchRequest () {
this.emit("LaunchRequest");
},
IntentA () {
// Do something
},
Unhandled () {
// Do something
}
});
I'm using Bespoken-tools
to test this skill with Mocha
, and when I directly feed IntentA
like so:
alexa.intended("IntentA", function (err, p) { /*...*/ })
The test complains, Error: No 'Unhandled' function defined for event: Unhandled
. From what I gather, this can only mean that the skill, at launch, is at blank state (because I have not defined any Unhandled
for that state), which must mean that alexa.state
isn't really a thing. But then that makes me wonder how they made it work in the example code above.
I guess a workaround for this would be to create an alias for EVERY intent that I expect to have in the START_MODE
, by doing:
IntentA () {
this.handler.state = states.START;
this.emitWithState("IntentA");
}
But I want to know if there is a way to force my skill to start in a specific state because that looks like a much, much better solution in my eyes.
via spicypumpkin
No comments:
Post a Comment