Search code examples
alexa-skills-kitalexa-interaction-model

How to disable certain intents in custom Alexa skill?


...
CountryIntent{ ... };
CityIntent{ ... };
YesIntent{ ... };
FallBackIntent{ ... };
...

I'm building custom Alexa skill. User calls CityIntent from CountryIntent. But, if user accidentally says YES, he'll call YesIntent from CountryIntent; that will be incorrect logic. How to disable YesIntent so that user calls FallBackIntent when he accidentally says YES?


Solution

  • You can't disable intents. By building intents you teach your skill to understand specific sentences/words spoken by human - and once taught, it's hard to forget.

    What you can actually do is build a state machine and keep the current state of your conversation in SessionAttribute. Then in each intent you have to check in which state the conversation is and act according to your logic - so in your case when you expect city and someone says "Yes", your skill should ask once again about the city and ignore the "yes" answer.