alexa-skills-kit-sdk-for-nodejs: The unhandled intent is never called

The app calls one of the defined intents even if the input doesn’t match any utterance. This is a simple skill to replicate the issue.

index.js

var Alexa = require('alexa-sdk');

exports.handler = function(event, context, callback){
    var alexa = Alexa.handler(event, context);
    alexa.registerHandlers(handlers);
    alexa.execute();
};

var handlers = {
    'Amazon.LaunchIntent': function () {
        this.emit(':ask', 'Welcome!', 'Welcome!');
    },
    'TestIntent': function () {
        this.emit(':ask', 'Test intent', 'Test intent');
    },
    'Unhandled': function () {
        this.emit(':ask', 'I don\'t get it!', 'I don\'t get it!');
    },
}

Intent Schema

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

Utterances TestIntent test

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 36

Most upvoted comments

I don’t think this should be closed as the behaviour is inconsistent.

When I implement an ‘Unhandled’ intent on a handler with no state, this ‘Unhandled’ intent will be called when the users says something which cannot be send to an Utterance/Intent (even if I don’t specify any ‘Unhandled’ utterances - which would be absurd because it’s impossible). This gives me the possibility to respond on unknown input, which is nice.

But when I define a ‘Unhandled’ intent inside a state, this ‘Unhandled’ intent doesn’t get called when the users says unknown input but instead the default ‘Unhandled’ intent with no state gets called. I think this is wrong.

By defining an ‘Unhandled’ intent inside a state I want the be able to response dynamically to the current state (obviously). Example: I ask the user who old she/he is. The user then tells me some unknown stuff whereupon my ‘Unhandled’ intent gets called. There I want to response with something like “Sorry, I did’t understand how old are you”. This will not work as of currently only the default ‘Unhandled’ intent would be called. A workaround could be to read the state attribute inside the default ‘Unhandled’ intent and then “redirect” to the state specific ‘Unhandled’ function. This is against the current art of handling state as I don’t want to have the state handling inside the intent, I want it to be outside.

// 'Unhandled' event in stateless handler
'Unhandled'() {
  if (this.handler.state) {
    // pass to state specific 'Unhandled' handler
    this.emitWithState('Unhandled');
  } else {
    // default 'Unhandled' handling
    this.emit(':ask', 'I didnt understand you. What did you say?, 'What did you say?');
  }
}

Just to clarify: issue is still open for me and I’m still looking for a resolution that’s not hacky, if anyone knows of one. Let me know if you find something.

Presently, Alexa’s NLP is horrible. Yes, you can bypass Alexa’s NLP for a 3rd party service. See my post here on how to achieve it.

I agree with @feedm3, this should not be closed, @knowlsie is correct, the skills test service emulator clearly demonstrates that entering utter gibberish is causing the NLP to match against the wrong intent, I am not looking for a workaround that will then have to be removed at some point, this should be fixed.

I am having this issue also. I played around some. This is not a very good solution but it is working for me.

I added these utterances:

UnhandledIntent a UnhandledIntent basd fasd UnhandledIntent cat video fun UnhandledIntent hdfasdf sdfas ewqrqwe

Anyone have a better work around. Also if we work togeather we can refine this list. Also this appears to be an issue with more than just this sdk. See https://forums.developer.amazon.com/questions/4856/intent-triggering-without-utterance-match.html

This has nothing to do with whether your code handles unhandled intents correctly. It’s to do with the fact that NLP does not resolve the intent correctly before sending.

If i have an intent with and utterance of “known intent”, if you then say “unknown intent” NLP will resolve this incorrectly to the known intent purely because it has two words!!!

If a user says something unknown, it resolves incorrectly and tries to call the resolved intent which will work incorrectly. NLP shoukd recognise it as unknown.

Chris

The Unhandled property for the current state will get called if the user invokes an intent which is not in the current state.

Consider the following states and intents:

//...
'START', {
  'AMAZON.YesIntent' : function() {

  }, 
  'AMAZON.NoIntent' : function() {
  }
}
//...
'QUIZ',  {
   'AMAZON.YesIntent' : function() {

  }, 
  'Unhandled' : function() {

   }
}

If the user is in QUIZ Mode and says ‘no’,

  1. alexa-sdk will check if QUIZ state has a NoIntent handler (it doesn’t)
  2. It will then check if there is a property ‘Unhandled’, which exists in quiz state, so it will be called.

This behaviour should not differ on device vs. simulator.