Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Null SpeechletResponse (Alexa)

Something is messed up with my AMAZON.StopIntent. No matter what I put there (I've tried everything from every tutorial), whenever it's called, I get "There was a problem with the requested skill's response" and the Alexa app shows the error as "speechletresponse cannot be null". My project is in the JSON, not Java format.

If anyone can help, I'd very much appreciate it!

Thanks!

As requested here's what is being sent to Lambda

{
  "session": {
    "sessionId": "SessionId.XXXXX",
    "application": {
      "applicationId": "amzn1.ask.skill.XXXXXXX"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.XXXXXXX"
    },
    "new": true
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.XXXXXX",
    "locale": "en-US",
    "timestamp": "2017-01-18T22:38:53Z",
    "intent": {
      "name": "AMAZON.StopIntent",
      "slots": {}
    }
  },
  "version": "1.0"
}

And here's the relevent code:

var handlers = {
    'LaunchRequest': function () {
        this.emit('AMAZON.HelpIntent');
    },
    'GetNewDogThoughtIntent': function () {
        this.emit('GetDogThought');
    },
    'GetNewCatThoughtIntent': function () {
        this.emit('GetCatThought');
    },
    'GetDogThought': function () {
        var dogthoughtIndex = Math.floor(Math.random() * DOGTHOUGHTS.length);
        var randomDogThought = DOGTHOUGHTS[dogthoughtIndex];

        // Create speech output
        var speechOutput = "Your dog is thinking, " + randomDogThought;

        this.emit(':tellWithCard', speechOutput, "Your dog was thinking... ", randomDogThought);
    },
    'GetCatThought': function () {
        var catthoughtIndex = Math.floor(Math.random() * CATTHOUGHTS.length);
        var randomCatThought = CATTHOUGHTS[catthoughtIndex];

        // Create speech output
        var speechOutput = "Your cat is thinking, " + randomCatThought;

        this.emit(':tellWithCard', speechOutput, "Your cat was thinking... ", randomCatThought);
    },
    'AMAZON.HelpIntent': function () {
        var speechOutput = "You can ask me for what your cat or dog is thinking, or you can say exit... Right now I can only provide thoughts for one cat or dog at a time... What can I help you with?";
        var reprompt = "What can I help you with? Make sure to say if your pet is a cat or dog when you ask!";
        this.emit(':ask', speechOutput, reprompt);
    },
    'SessionEndedRequest': function (sessionEndedRequest, session) {
    },
    "AMAZON.StopIntent": function (shouldEndSession) {
    }
like image 222
Branch Avatar asked Dec 30 '16 14:12

Branch


Video Answer


2 Answers

I finally got it after consulting the SpaceGeek tutorial again and making some tweaks to it. Basically, here's what worked:

'AMAZON.StopIntent': function () { 
    this.emit(':tell', "Goodbye!");
}

The key was the ':tell', which I didn't have before. Thanks to everyone who answered and helped!

like image 54
Branch Avatar answered Oct 27 '22 13:10

Branch


Can you post your code for the StopIntent? You should be calling a speechlet response in it. For example:

'AMAZON.StopIntent': function (shouldEndSession, response) {
    var speechOutput = "Goodbye";
    response.tell(speechOutput); 
},

Are you building that response properly and passing it?

like image 21
AppleBaggins Avatar answered Oct 27 '22 12:10

AppleBaggins