Search code examples
alexa-skills-kitalexa-voice-servicealexa-slot

How to fire fallbackIntent even if user's dialogue fall into some other intent


I am developing an app and everything is working good. One condition are there where I have set the utterances but if user is speaking something else, I am throwing it to the fallbackIntent. One of my utterance is {name} so user can speak any name. But I have define range of name as well that user is allowed only these names. So my problem is if the user is choosing defined names, everything working great and if user said something else like what is weather of chicago, it is going to fallbackIntent as well but the issue is if user speak some name which is not in the list, then too it is coming into defined intent. What i want that if user speak something which is correct but not in my defined name then too redirect it to the fallbackIntent. Is there any way I can call intent in giving condition? I am using php.


Solution

  • When you define a custom slot, Alexa take it's values as samples. So values which are not in the slot-value-list will also be passed to you. And with respect your intent, those slot values are valid, hence that intent is triggered.

    The solution is to validate the slot values at your backend and return an appropriate response.

    In your case, if u get any other names other than those you have defined, respond back with an error or give FallbackIntent's response.

    When you create a custom slot type, a key concept to understand is that this is training data for Alexa’s NLP (natural language processing). The values you provide are NOT a strict enum or array that limit what the user can say. This has two implications

    1) words and phrases not in your slot values will be passed to you,

    2) your code needs to perform any validation you require if what’s said is unknown.