Search code examples
alexa-skills-kitalexa-slot

My custom slot type is taking on unexpected values


I noticed something strange when testing my interaction model with the Alexa skills kit.

I defined a custom slot type, like so:

CAR_MAKERS Mercedes | BMW | Volkswagen

And my intent scheme was something like:

{
  "intents": [
    {
      "intent": "CountCarsIntent",
      "slots": [
        {
          "name": "CarMaker",
          "type": "CAR_MAKERS"
        },
   ...

with sample utterances such as:

CountCarsIntent Add {Amount} cars to {CarMaker}

Now, when testing in the developer console, I noticed that I can write stuff like:

"Add three cars to Ford"

And it will actually parse this correctly! Even though "Ford" was never mentioned in the interaction model! The lambda request is:

  "request": {
    "type": "IntentRequest",
    ...
    "intent": {
      "name": "CountCarsIntent",
      "slots": {
        "CarMaker": {
          "name": "ExpenseCategory",
          "value": "whatever"
        },
 ...

This really surprises me, because the documentation on custom slot types is pretty clear about the fact that the slot can only take the values which are listed in the interaction model.

Now, it seems that values are also parsed dynamically! Is this a new feature, or am I missing something?


Solution

  • Actually that is normal (and good, IMO). Alexa uses the word list that you provide as a guide, not a definitive list.

    If it didn't have this flexibility then there would be no way to know if users were using words that you weren't expecting. This way you can learn and improve your list and handling.