Alexa Spelling Skill - How to trigger answer intent when a word is misspelledc

I am currently writing a alexa spelling skill to ask different spellings and to check user input according to the data we have. I created below intents & slots to do the expected work:

Intents: SpellingIntent - Ask a random word from the list of words AnswerIntent - Validate the user input

Slots: Words - to keep track of all the words Spellings - Spellings of words in dot separated format

For example if the word is apple, then spellings slot would have a.p.p.l.e

My app is working fine if the user spelled the word correctly, but if the user misspelled the word then I am not getting event till answerIntent to validate.

I researched about this and I found that amazon deprecated Amazon.LITERAL built in slot type to trigger any word spoken by user and I have to use SearchQuery. But I am not getting how to get the event fired to my answer intent whatever the user said.

Could anyone help me out to figure this?

Upvotes: 1

Views: 485

Answers (1)

Josh
Josh

Reputation: 1647

I haven't tested this but I would suggest trying the following as a solution.

1 - Stop using AMAZON.SearchQuery, instead define a custom slot value like the below:

{
  "types": [
    {
      "name": "LETTER",
      "values": [
        {
          "name": {
            "value": "a",
            "synonyms": []
          }
        },
        {
          "name": {
            "value": "b",
            "synonyms": []
          }
        },
        {
          "name": {
            "value": "c",
            "synonyms": []
          }
        },

        // ... and so on

      ]
    }
  ]
}

2 - Redefine your AnswerIntent to accept varying quantities of the LETTER slot value, like the below:

{
  "intents": [
    {
      "name": "AnswerIntent",
      "slots": [
        {
          "name": "LetterOne",
          "type": "LETTER"
        },
        {
          "name": "LetterTwo",
          "type": "LETTER"
        },
        {
          "name": "LetterThree",
          "type": "LETTER"
        },

        // ... and so on

      ],
      "samples": [
        "{LetterOne}",
        "{LetterOne} {LetterTwo}",
        "{LetterOne} {LetterTwo} {LetterThree}",

        // ... and so on

      ]
    }
  ]
}

In theory, this set up should trigger the AnswerIntent any time a user speaks a sequence of letters. You should then be able to collect the letters passed through in slot values and compare them against the correct spelling.

As a potential additional step you could try adding synonyms to the slot values for phonetically matching words such as the below. Then access the slots in your code via the key value.

{
  "name": {
    "value": "b",
    "synonyms": [
      "be",
      "bee"
    ]
  }
}

Upvotes: 0

Related Questions