Closed kimhyunj closed 6 years ago
You need to pass a prompt message as a parameter to the listen function.
Because you didn't do this, Alexa gives an "undefined" string in the response. And because you don't response, after a set amount of time elapses, Alexa will send a sessionEndRequest.
'Unhandled': function() { console.log("IN UNHANDLED: \n", this.event.request); let msg = "I don't understand that. Please say a valid command"; this.response.speak(msg).listen(msg); this.emit(':responseReady'); }
The fact that I don't provide a string as a parameter .listen() is not the source of this error, because Alexa sends a SessionEndedRequest even before reaching to that this.response.speak(msg).listen() line. Alexa does not even say the parameter that was passed in as the message of this.response.speak().
I think it has to do with the fact that I'm still trying to send a response back when receiving a SessionEndedRequest.
If that is the case, you should look in the error section of the SessionEndedRequest event in the logs for clues. If have sometimes found good clues for debugging in the error section (e.g. an SSML syntax exception or some other issue). Good luck!
I'm running into a very similar issue as here: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues/192
What I would like my Alexa to do is that, when the user says a command/utterance that is unknown, Alexa will say something like "I don't understand that. Please say a valid command" and prompt the user again.
To do that, in my Unhandled() function, I'm trying to emit() something so that Alexa would say something back to a user. I have tried emitting :responseReady, :tell, and :ask. Below is an example of what I have written for Unhandled().
'Unhandled': function() { console.log("IN UNHANDLED: \n", this.event.request); this.response.speak("I don't understand that. Please say a valid command").listen(); this.emit(':responseReady'); }
However, this is where the problem arises. When I say an utterance to an unknown intent, instead of saying the specified message, Alexa just simply says "undefined".
According to the log, it seems like when Unhandled() is getting called, the type of the request of the session is SessionEndedRequest. The SDK documentation specifies that no response can be sent back to Alexa when the request type is SessionEndedRequest. And because I'm trying to send a response back in Unhandled()
What could be the solution to the problem? I would really want Alexa to prompt the user after receiving an unknown intent.