alexa-samples / skill-sample-nodejs-buttons-trivia

This is a sample trivia skill that will allow developers to get a head start on their trivia games using Echo Buttons. It allows for roll-call of the players, asking trivia questions, and determining whether the voice inputs matched the answers.
Other
32 stars 35 forks source link

AnswerOnlyIntent and PlayerCount mixed up #7

Closed oliviachang29 closed 6 years ago

oliviachang29 commented 6 years ago

I want users to be able to answer trivia questions with a number, instead of a word, so I changed the slot type of AnswerQuestionIntent and AnswerOnlyIntent to "AMAZON.NUMBER" (instead of the slot type "answers").

But the dialog ends up like this:

Alexa: Welcome to Better With Buttons Trivia. This game supports up to 4 players. How many players are there?
User: two
Alexa: Sorry, I didn't get that. Please say again!

(note: if the user responds with anything other than a number, Alexa will say "Welcome to Better with Buttons Trivia. This game supports up to 4 players. How many players are there?")

Looking at debugging info from the Device Log, I can see that Alexa thinks that the intent is AnswerOnlyIntent, instead of PlayerCount:

 "request": {
    "type": "IntentRequest",
    "intent": {
        "name": "AnswerOnlyIntent",
        "confirmationStatus": "NONE",
        "slots": {
            "answers": {
                "name": "answers",
                "value": "2",
                "confirmationStatus": "NONE"
            }
        }
    }
}

Why does Alexa think that the user wants AnswerOnlyIntent instead of PlayerCount, and how can I fix this? It looks to me from the handlers that AnswerOnlyIntent should only be called when the game state is settings.STATE.BUTTON_GAME_STATE or settings.STATE.BUTTONLESS_GAME_STATE.

I also made a StackOverflow issue here.

justinpecott commented 6 years ago

I don't know that there is a deterministic way to anticipate which intent Alexa will call when there are multiple that match to the same utterance - in this case a number. I liked Cicil's answer at StackOverflow, to just have one number intent. After that if you update the canHandle methods of PlayerCountHandler and AnswerHandler to look for that intent instead of the previous ones you should have what you want.