alexa-samples / skill-sample-nodejs-fact

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

Intent call not working, Alexa close session after LaunchRequest. #102

Closed shvedPetro closed 5 years ago

shvedPetro commented 5 years ago

After i call "open space facts". It's give me a fact, but if after i say "tell me a fact", it's not working, "Sorry, I don't know that". But if i put .reprompt(speakOutput) after line 27 in index.js, it's start working well.

vCarly commented 5 years ago

That doesn't look like the right line number for me... what is the text of the line you put that after to make it work? Did you discover anything else using this example?

franklin-lobb commented 5 years ago

The skill is designed to tell a fact and then exit, so the behavior @shvedPetro describes is expected.

The .reprompt(repromptOutput) would be added to the GetNewFactHandler, in this part of the code:

    return handlerInput.responseBuilder
      .speak(speakOutput)
      .withSimpleCard(requestAttributes.t('SKILL_NAME'), randomFact)
      .getResponse();

modifying it to listen for a response (and reusing the speak output value in this example, however whenever you are reprompting, the output should end with a question which the fact does not)

    return handlerInput.responseBuilder
      .speak(speakOutput)
      .reprompt(speakOutput)
      .withSimpleCard(requestAttributes.t('SKILL_NAME'), randomFact)
      .getResponse();
chfw commented 5 years ago

Alexa and I were confused about invocation name and intent's slots. If speaking out invocation name to Alexa would trigger a piece of space facts, why bother intent's slots? i.e.

- Alexa, open space facts.
- Here is a piece of fact, the sun....
- tell me a fact
..(silent)..

I am also confused, if there are alternatives to trigger the skill?

franklin-lobb commented 5 years ago

Space facts is a simple skill which only does one thing - tell you a fact. As a result, invoking the skill essentially does the same thing as invoking the skill and asking for a fact in a single utterance. However, since the session is not kept open (in the way the code is currently setup), it is not possible to access the other functionality (like help), without combining it into a single utterance along with invoking the skill. Since there are other intents, the Get Fact intent must also exist.

There are also multiple words and phrasing you can use to invoke a skill. Check this out: https://developer.amazon.com/docs/custom-skills/understanding-how-users-invoke-custom-skills.html