alexa-skills-kitalexa-slotamazon-echo

How do I handle 'Yes'/'No' responses from the user in Custom Skill?


I am trying to build an alexa custom skill. I am facing an issue where I am trying to get Yes/No responses from the user for a question which the skill asks the user.

Alexa: Would you like to know the rules of the game?
User: <Can respond either Yes or No>

Based on the user response I would like to perform a specific action.

Here is my intent schema:

{
    "intents": [
    {
        "intent": "AMAZON.StopIntent"
    },
    {
        "intent": "AMAZON.CancelIntent"
    },
    {
        "intent": "AMAZON.HelpIntent"
    },
    {
        "intent": "StartGame"
    },
    {
        "intent": "GetRules"
    }
  ]
}

Here are my sample utterances:

StartGame Begin the game
StartGame Start the game

GetRules What are the rules
GetRules Get the rules
GetRules Tell me the rules
GetRules Tell me the rules again

The question the skill asks the user is below:

Welcome to the game. Would you like me to tell you the rules?

Whenever I say "Yes", the StartGame intent is what is being triggered. (Same is the case for "No"). Alexa picks the intent as StartGame always. What is the best way to invoke "GetRules" intent. I want the user to just say Yes/No and not say "Get the rules".

Please let me know if this has been already answered/more information is needed.


Solution

  • You need to use AMAZON.YesIntent and AMAZON.NoIntent.

    You can read about them here:.

    Standard Built-in Intents. https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/standard-intents