How do I define a custom slot type that isn't a list?
Asked Answered
L

5

30

I'm playing around with the Alexa Skills Kit (for the Amazon Echo) and want to create a skill that would send the intent to an AWS Lambda function which would just email something back to me.

Sample Utterances would be something like this:

MemoIntent take a memo {myMemo}
MemoIntent to take a memo {myMemo}
MemoIntent send a memo {myMemo}

This would allow me to say something like "Alexa, ask my secretary to take a memo, remind me to go to the store on my way home today" and would then get an email from my Lambda function saying, "remind me to go to the store on my way home today."

The myMemo slot is freeform - at this point just a sentence or two will do, but I'm not finding a lot of help in the documentation for how to write the schema for something like this. My best guess at the moment fails with a:

Error: There was a problem with your request: Unknown slot name '{myMemo}'. Occurred in sample 'MemoIntent take a memo {myMemo}' on line 1.

I'm using the AMAZON.LITERAL slot type, which the documentation discourages, but it also doesn't offer any suggestions on how else to go about this. And besides, like I mentioned, it fails.

Here is the schema that fails:

{
    "intents": [
        {
            "intent": "MemoIntent",
            "slots": [
                {
                    "name": "myMemo",
                    "type": "AMAZON.LITERAL"
                }
            ]
        }
    ]
}
Lashelllasher answered 1/12, 2015 at 22:15 Comment(0)
M
23

Literals are different than other slot types in that you must provide training in the sample utterance, as mentioned in the official documentation: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference

Sample Utterances Syntax

Sample utterances map the phrases the user can speak to the intents you have defined. They are written as lines in a plain text file, using the following format:

IntentName  this is a sample utterance with no slots
IntentName  this is a sample utterance containing a {SlotName}
IntentName  this is a sample utterance containing a {SlotName} and {AnotherSlotName}

Note that the above format applies to all slot types except AMAZON.LITERAL. For AMAZON.LITERAL, you also need to specify a sample slot value:

IntentName  this is a sample utterance containing a {slot value|SlotName} using LITERAL

Alternatively, using Custom Slots will allow you to provide the slot after defining numerous sample custom slot values. In this scenario, you would create a new custom slot called myMemo with a type of the custom slot name, such as MY_MEMO. Your custom slot value would be populated with potential values (these are not the only values it will receive), such as:

walk the dog
eat more bacon
go to the store on the way home
Maurer answered 4/12, 2015 at 0:29 Comment(9)
Can you elaborate on "These are not the only values it will receive". Are these samples or guides for the Skill Kit on how long the slot phrase value can be or something?Wilonah
That's correct! They are not strictly matched or enum values, so they serve as a training data to offer better weight what Alexa heard. Using the example above, 'walk the cat' would still be heard and shown as the customSlot.value, but a situation where Alexa heard 'eat more baking' may adjust what it heard since 'eat more bacon' may be a more desired user request.Maurer
It still doesn't work for me. I created a custom slot type called 'Lead Name' and entered a couple of new line separated values for it. Alexa works iff one of those specified values is spoken, but not random names. What am I missing?Pga
I was looking at the same thing and kind of concluded that alexa as of now is extremely limited compared to its potential future competitors (google now and siri). You basically can't ask alexa to write anything for you (email,tweet,facebook post) with such schema. Meanwhile, on siri you can do it..Stumpf
The LITERAL type is being deprecated... which unfortunately makes Alexa look even more limited compared to its competitors.Rillis
@JasonSteele It is being deprecated, but only because you can still get any value you want from the user using the custom slot type - you give a few sample values, but it will still return any phrase said by the user.Pandich
@Pandich Yes, I just managed to confirm that. I had to add quite a few sample sentences in before I would accept any sentence, but it does appear to work. Seems strange though - having to make up a lot of rubbish to act as a wildcard.Rillis
This just barely touches on what i need... I need to see the my_memo example... Anyone know where i can find that?Livelong
AMAZON.LITERAL is still around but only available for English (US) skills. developer.amazon.com/docs/custom-skills/…Thorite
I
5

We are currently developing an AI (for Alexa) which should be able to answer a wide variety of questions. It is very important that users are able to phrase complex questions which shall be analyzed in the backend. If Alexa drops them early on because of limited utterances and slot types, we can't provide such a service.

At the moment we are experimenting with the following approach. (Keep in mind that our experiment is based on German. Other languages might behave differently.)

1. Custom Slot Types per Word Class

We defined custom slot types for the following word classes:

  • interrogation (what, who, when)
  • item (cybersecurity, darknet, malware)
  • verb (is, has, can)
  • adjective (popular, inexpensive, insecure)
  • pronoun (the, he, she)

2. Sample Utterances for Sentence Structure

Then we have defined possible structures for sentences with sample utterances:

QuestionIntent {Interrogation}
QuestionIntent {Item}
QuestionIntent {Verb}
QuestionIntent {Adjective}
QuestionIntent {Interrogation} {Verb} {Item}
QuestionIntent {Interrogation} {Verb} {Item} {Adjective}
QuestionIntent {Interrogation} {Verb} {Pronoun} {Item}
QuestionIntent {Interrogation} {Verb} {Pronoun} {Pronoun} {Item}
QuestionIntent {Interrogation} {Verb} {Pronoun} {Item} {Preposition} {Item}
QuestionIntent {Interrogation} {Verb} {Adjective} {Item}
QuestionIntent {Interrogation} {Verb} {Pronoun} {Adjective} {Item}
QuestionIntent {Interrogation} {Item} {Verb}
QuestionIntent {Interrogation} {Item} {Verb} {Adjective}
QuestionIntent {Interrogation} {Item} {Verb} {Pronoun} {Adjective}
QuestionIntent {Item} {Verb} {Interrogation}
QuestionIntent {Verb} {Item} {Verb}
QuestionIntent {Verb} {Adjective} {Item} {Verb}

3. NLP Analysis in Backend

Then we do an NLP analysis of the submitted words in the backend. The received data looks like this:

"intent": {
      "name": "QuestionIntent",
      "slots": {
        "Item": {
          "name": "Item",
          "value": "darknet"
        },
        "Preposition": {
          "name": "Preposition"
        },
        "Adjective": {
          "name": "Adjective"
        },
        "Verb": {
          "name": "Verb",
          "value": "is"
        },
        "Interrogation": {
          "name": "Interrogation",
          "value": "what"
        },
        "Pronoun": {
          "name": "Pronoun",
          "value": "the"
        }
      }
    }

Some words might be lost, some others might be misheard. In this case, we remember topics from earlier exchanges and "fill" the missing words with these. For example: What is {it}?What is {Darknet}?

We were experimenting with a broad list of lists for slot types. But this increases the risk of mishearing something (a good example in English is write and right, luckily they are not assigned to the same word class). So we switched to a very narrow approach. The lists only contain words which can be handled by the AI and are stored in the knowledge base. For example, the list of items does not contain the words pony or unicorn. We expect this to come up with better results (less confusing answers).

Complex sentences not defined with a utterances structure are highly confusing to work with. For example, if a sentence contains more than 2 verbs (which might be necessary to build tense). But so far our approach leads to results with a good level of accuracy as long as the user behaves with some level of politeness.

But in the end: Unfortunately, at the moment, it is not possible to dictate something like a memo with an infinite amount of different words and sentence structures.

Ideo answered 24/8, 2017 at 9:14 Comment(0)
C
1

I tried another approach to this.

I created a Custom Slot Type with a list of values like this.

wordOne
wordOne wordTwo
wordOne wordTwo wordThree
wordOne wordTwo wordThree wordFour
wordOne wordTwo wordThree wordFour wordFive

You can continue the list with as long strings as you need.

My guess was that Alexa, when trying to fill slots, orientates on the amount of space seperated words in a value of a slot type, to match what it heard.

I had quite some success grabbing whole sentences in a single slot with this Custom Slot Type. Though i have never tested it on intents with more than just the slot as utterance.

But if you seperate your intent it might work. Maybe something like this.

StartMemoIntent take a memo
StartMemoIntent to take a memo
StartMemoIntent send a memo
StartMemoIntent record a memo
StartMemoIntent listen to my memo
RecordMemoIntent {memo}

You have to be careful though, it can confuse the intents if you have not enough sample utterances for your other intents.

If you put enough sample utterances, at least 7-8, with the StartMemoIntent it should have no problem taking the right one.

Creditable answered 15/12, 2017 at 9:21 Comment(0)
N
1

According to some of the comments here, I figured out you can get Alexa to recognise free form words or phrases by adding a large random list of words to the custom slot values field.

I generated mine by running;

from nltk.corpus import words
import json

words_list = words.words()[:100]

values = []
for word in words_list: 
    value = {}
    value['id'] = None
    value['name'] = {}
    value['name']['value'] = word
    value['name']['synonyms'] = []
    values.append(value)

print(json.dumps(values))

Then copy pasting those values to;

{
  "languageModel": {
    "types": [
      {
        "name": "phrase",
        "values": [values you get from above]
...
Napkin answered 3/2, 2018 at 19:32 Comment(0)
C
1

AMAZON.SearchQuery

AMAZON.SearchQuery slot type lets you capture less-predictable input that makes up the search query.

Ex:

{
  "intents": [
    {
      "name": "SearchIntent",
      "slots": [
        {
          "name": "Query",
          "type": "AMAZON.SearchQuery"
        },
        {
          "name": "CityList",
          "type": "AMAZON.US_CITY"
        }
      ],
      "samples": [
        "search for {Query} near me",
        "find out {Query}",
        "search for {Query}",
        "give me details about {CityList}"
      ]
    }
  ]
}

More on AMAZON.SearchQuery here

There is AMAZON.LITERAL slot that passes the recognised words for the slot value with no conversion. But, its's not recommended. You cannot use AMAZON.LITERAL in a skill configured with a dialog model.

Crockery answered 1/9, 2018 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.