alexa / alexa-skills-kit-sdk-for-java

The Alexa Skills Kit SDK for Java helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
http://developer.amazon.com/ask
Apache License 2.0
818 stars 748 forks source link

.addDelegateDirective to cause alexa to begin the dialog #259

Closed harry-levick closed 4 years ago

harry-levick commented 4 years ago

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Other... Please describe:

I am trying to trigger Alexa to begin a dialog so that she asks the user to give the required slots for a given intent. I have made a language model such that DiagnosisIntent has 2 required slots. And I have added a dialog with prompts for those slots.

{
  "interactionModel": {
    "languageModel": {
      "invocationName": "diagnose",
      "intents": [
        {
          "name": "AgeIntent",
          "slots": [
            {
              "name":  "age",
              "type":  "AMAZON.NUMBER"
            }
          ],
          "samples": [
            "{age}",
            "I am {age}",
            "I'm {age}",
            "I am {age} years",
            "I'm {age} years",
            "I am {age} years old",
            "I'm {age} years old",
            "I was born {age} years ago",
            "I am the old age of {age}",
            "I am the ripe old age of {age}"
          ]
        },
        {
          "name": "BeginDiagnosisIntent",
          "slots": [
            {
              "name": "age",
              "type": "AMAZON.NUMBER"
            },
            {
              "name": "gender",
              "type": "GENDER"
            }
          ],
          "samples": [

          ]
        },
        {
          "name": "AMAZON.RepeatIntent"
        },
        {
          "name": "AMAZON.HelpIntent"
        },
        {
          "name": "AMAZON.StopIntent"
        },
        {
          "name": "AMAZON.CancelIntent"
        }
      ],
      "types": [
        {
          "name": "GENDER",
          "values": [
            {
              "id": "MALE",
              "name": {
                "value": "male",
                "synonyms": [
                  "man",
                  "boy"
                ]
              }
            },
            {
              "id": "FEMALE",
              "name": {
                "value": "female",
                "synonyms": [
                  "woman",
                  "girl"
                ]
              }
            }
          ]
        }
      ]
    },
    "dialog": {
      "delegationStrategy": "ALWAYS",
      "intents": [
        {
          "name": "BeginDiagnosisIntent",
          "prompts": {},
          "slots": [
            {
              "name": "age",
              "type": "AMAZON.NUMBER",
              "confirmationRequired": false,
              "elicitationRequired": true,
              "prompts": {
                "elicitation": "Elicit.Slot.1323207333291.854898796228"
              }
            },
            {
              "name": "gender",
              "type": "GENDER",
              "confirmationRequired": false,
              "elicitationRequired": true,
              "prompts": {
                "elicitation": "Elicit.Slot.1323207333291.563366041005"
              }
            }
          ]
        }
      ]
    },
    "prompts": [
      {
        "id": "Elicit.Slot.1323207333291.854898796228",
        "variations": [
          {
            "type": "PlainText",
            "value": "How old are you?"
          }
        ]
      },
      {
        "id": "Elicit.Slot.1323207333291.563366041005",
        "variations": [
          {
            "type": "PlainText",
            "value": "Are you male of female?"
          }
        ]
      }
    ]
  }
}

I want to trigger this dialog from the LaunchHandler.handle() method. From what I understand, I do this using the following code:

Intent chainedIntent = Intent.builder().withName("BeginDiagnosisIntent").build();

return handlerInput.getResponseBuilder()
    .addDelegateDirective(chainedIntent)
    .build();

I expect this to cause Alexa to use the prompt to ask me for one of the slots that has not been filled yet. But instead, this response is generated and Alexa says There was a problem with the requested skill's response.

{
    "body": {
        "version": "1.0",
        "response": {
            "directives": [
                {
                    "type": "Dialog.Delegate",
                    "updatedIntent": {
                        "name": "BeginDiagnosisIntent",
                        "slots": {}
                    }
                }
            ],
            "type": "_DEFAULT_RESPONSE"
        },
        "userAgent": "ask-java/2.16.0 Java/11.0.7"
    }
}
ghost commented 3 years ago

Hey, did you find a solution to this problem? I'm facing a similar issue, it would really be helpful if you could explain it. Thanks in advance!

Jayanth-21 commented 3 years ago

Hey, did you find a solution to this problem? I'm facing a similar issue, it would really be helpful if you could explain it. Thanks in advance!