Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only getting single word parameters from Alexa Skills Kit

I'm writing an Alexa Skill, and I can only get single word parameters into my code.

Here is the intent schema:

    {
  "intents": [
    {
      "intent": "HeroQuizIntent",
      "slots": [
        {
          "name": "SearchTerm",
          "type": "SEARCH_TERMS"
        }
      ]
    },
    {
      "intent": "HeroAnswerIntent",
      "slots": [
        {
          "name": "SearchTerm",
          "type": "SEARCH_TERMS"
        }
      ]
    },
    {
      "intent": "AMAZON.HelpIntent"
    }
  ]
}

and my sample utterances are:

HeroQuizIntent quiz me
HeroAnswerIntent is it {SearchTerm}

For the HeroAnswerIntent, I'm checking the SearchTerm slot, and I'm only getting single words in there.

So, "Peter Parker" gives "Parker", "Steve Rogers" gives "Rogers", and "Tony Stark" gives "Stark".

How do I accept multiple words into a slot?

like image 290
Xanxir Avatar asked Apr 07 '16 16:04

Xanxir


People also ask

What are the specific phrases that people will use when making a request to Alexa?

Utterance. Utterances are the specific phrases that people will use when making a request to Alexa.

What language is Alexa skills written?

js, Java, Python, C#, Go, Ruby, or PowerShell. You can author a web service in any language appropriate for web services. If you choose the Alexa-hosted skill option, you write your code in Node. js and Python.


1 Answers

I've had same problem with my skill and that's the only solution which is worked for my skill to use several words, but you need to check are these slots not empty and concatenate them

Intent schema:

{
  "intent": "HeroAnswerIntent",
  "slots": [
    {
      "name": "SearchTermFirst",
      "type": "SEARCH_TERMS"
    },
    {
      "name": "SearchTermSecond",
      "type": "SEARCH_TERMS"
    },
    {
      "name": "SearchTermThird",
      "type": "SEARCH_TERMS"
    }
  ]
},

Sample utterance

HeroAnswerIntent is it {SearchTermFirst} HeroAnswerIntent is it {SearchTermFirst} {SearchTermSecond} HeroAnswerIntent is it {SearchTermFirst} {SearchTermSecond} {SearchTermThird}

And last one you need to put every of your words in separate line in SEARCH_TERMS slot definition

Also using AMAZON.LITERAL sometimes not pass variable into skill at all even if you test it using service simulator (skill console, test tab)

like image 131
Rostyslav Antonov Avatar answered Oct 03 '22 16:10

Rostyslav Antonov