alexa-samples / skill-sample-nodejs-fact

Build An Alexa Fact Skill
Apache License 2.0
1.15k stars 1.19k forks source link

Immediately ends session after telling fact #22

Closed jersharocks closed 7 years ago

jersharocks commented 7 years ago

I used this code to make a fact skill but it immediately ends the session after giving the fact. Just saying "Alexa, open ___ facts" gives the fact and then is done. How can I get the session to stay open? I cannot figure it out. I have tried adding more intents. I've tried adding to the code. I'm definitely a newbie but I can usually figure things out but this is driving me nuts. I just want the skill to let me go through more than 1 fact. Ideally, the user could ask for facts over and over again and then just say stop or stop using it then it closes. Is this too advanced of a program for a beginner to try?

RollandWaters commented 7 years ago

I'm seeing this as well. In the Developer test, asking "help" gives this (partial snippet) in the response: "shouldEndSession": false }, "sessionAttributes": {}

But a fact utterance gives this: "shouldEndSession": true }, "sessionAttributes": {} Beta testing with a wand shows it does not exit when asked for help, but does exit after a single fact.

RollandWaters commented 7 years ago

As I look at the HelloWorld alexaSkill.js, e.g.:

https://github.com/amzn/alexa-skills-kit-js/blob/6c59448d8bb2701433ab7e117574199012bedd3f/helloWorld/src/AlexaSkill.js, "shouldEndSession" seems to be intentionally set to true:

    _tell: function (speechOutput) {
        this._context.succeed(buildSpeechletResponse({
            session: this._session,
            output: speechOutput,
            shouldEndSession: true
        }));
    },_

The documentation there indicates that this should get overridden with a local tell function, and of course there is no override in the sample here .

RollandWaters commented 7 years ago

After a conversation with Robert McCauley in yesterday's Alexa Dev Office Hours, it appears that this behavior on part of Alexa is intentional.

That is to say, Alexa's conversational model is inherently transaction from a speech acts theory perspective, and not currently intended to have a Tell / (natural timeout) or a Tell / (natural pause before the next step).

The supported pattern is :ask with a reprompt, and it appears that the reprompt utterance is mandatory and therefore doesn't fit with the sample expectation. YMMV.

I think this can be implemented if desired with an override, but AlexaSkills.js is apparently deprecated.

The current examples are in:

https://github.com/alexa/alexa-cookbook

but I have not had a chance to inspect them to see what the appropriate workaround is.

jeffblankenburg commented 7 years ago

@jersharocks this is the intended behavior, but it is relatively easy to modify. Search your code file for ":tell", and change it ":ask". This will tell Alexa to keep the microphone open after she provides a fact, and allow the user to ask for another.

Keep in mind that you will also have to append something to Alexa's response to ask the user a question, like "What would you like to do now?" so that the user can ask for another fact.

benzevl commented 6 years ago

could this be updated with current examples?

franklin-lobb commented 6 years ago

@benzevl this is a really old issue. Can you open a new issue with more details about what you're looking for? This sample was updated recently with the new SDK. Did you want more facts, different features? Some of the other sample skills might give you what you're looking for.