Questions tagged [alexa-slot]

A container used by Alexa, capable of holding useful piece of information provided by user like Date, Time, City, Country, Fictional Character, Author, Movies, etc.

Source : https://developer.amazon.com/docs/custom-skills/slot-type-reference.html#list-slot-types

Alexa Skills kit supports slot, which are basically containers which are helpful in obtaining specific data which the user has provided in any format to the skill. This input data is useful for the developer to return the necessary response.

For example : Consider you're making a skill which tells you the day of a particular date. More precisely, you give Alexa a date and it returns you the day of the week.

Slots would be useful to obtain the input data Date which the user has specified, and using some logic we can figure out the day for that date.

Consider this conversation:

User: "Alexa launch days of our life"

Alexa: "Welcome to the days of our life". // "days of our life" is the invocation name of this hypothetical skill.

User: "What was the day on {1st May, 1996}" // {1st May, 1996} is the value received by slot {Date}

Alexa: "It was a Wednesday".

Slots Type

The Alexa Skills Kit supports several slot types that define how data in the slot is recognized and handled. There are built-in slot (list of slot types), as well as the developer can specify their own custom slot. When creating their custom slots they are required to give some slot values, in the Alexa skill builder's build section. When the Alexa skill comes across such values, it would know these are the slot values of the custom build slot.

Since the skill can be published in several languages (see languages supported by Alexa), the build-in slots are also supported in several languages.

Defining slots

Slots may be defined in the Build section of new Alexa skill builder or using the JSON Editor to edit the Intent Schema.

This is how the slots Query and CityList are defined in the intent schema.

{
  "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}"
      ]
    }
  ]
}

Synonyms for slot values

The slot values defined in Alexa skill builder can have synonyms too. For example, if you're working with a skill which asks for the city in which the user lives, then places like Mumbai and Banglore could have synonyms Bombay and Bengaluru, respectively.

Custom Slot Example

Slot Filling

For filling slots there are two cases which the developer must understand.

  1. Slot value is always required.
  2. Slot value is sometimes required, i.e. the skill will still work if this slot is missing.

If the slot value is always required, then the Directive Dialog.Delegate may be used. To use this directive, prompts (i.e. what Alexa will say to ask for the value of this slot) and utterances (i.e. what user will speak in response to those prompts) should be defined in the Alexa skill builder.

Like this : Here the prompts and utterances are given for the custom slot CITY which is required by Intent GetMoviesNowShowing. (It is a built-in slot of type AMAZON.City)

Prompts and Utterances for custom slot - CITY

And if the slot is not always required, then the Directive Dialog.ElicitSlot may be used. For this directive no prompts and utterances are required, the developer has to provide explicit outputSpeech, which is used by Alexa as a prompt for the slot filling.

Accessing slot values

The slot values may be accessed in the lambda function. When an intent is invoked, a JSON input is given to the lambda function. Developer can access this JSON input to retrieve the slot value input given by the user. It looks something like this:

"intent": {
    "name": "GetAntonymsIntent",
    "confirmationStatus": "NONE",
    "slots": {
        "LANGUAGE": {
            "name": "LANGUAGE",
            "confirmationStatus": "NONE",
            "value" : "english"
        },
        "WORD": {
            "name": "WORD",
            "value": "ace",
            "resolutions": {
                "resolutionsPerAuthority": [
                    {
                        "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.c4a5d570-8455-4496-825b-07864b4acfec.WORD",
                        "status": {
                            "code": "ER_SUCCESS_MATCH"
                        },
                        "values": [
                            {
                                "value": {
                                    "name": "ace",
                                    "id": "360e2ece07507675dced80ba867d6dcd"
                                }
                            }
                        ]
                    }
                ]
            },
            "confirmationStatus": "NONE"
        }
    }
}

This is just a concerned part of JSON input. This is not the complete input. The complete input / event looks something like this.

Here the slots LANGUAGE and WORD have values "english" and "ace", respectively.

There can be as many slots as the developer desire, but having a lot of them increases the complexity of the skill.

Questions related to any topic discussed above should have this tag, along with tags like Alexa and Alexa-skills-kit.

224 questions
11
votes
2 answers

Alexa ask a question and get response from external API

I have set up a simple intent { "interactionModel": { "languageModel": { "invocationName": "viva bank", "intents": [ ...builtin intents...{ "name": "ask", "slots": [{ "name":…
Nick Ellis
  • 1,048
  • 11
  • 24
10
votes
2 answers

How to check and get Alexa slot value with Python ask sdk

In my interaction model I defined a slot named city that is optional, not required, to fulfill an intent. I'm using the python ask sdk, so my handler is this: class IntentHandler(RequestHandler): """ Intent handler """ def…
Nicolò Gasparini
  • 2,228
  • 2
  • 24
  • 53
10
votes
4 answers

Alexa Skill - How to get complete text of statement asked to alexa

I am creating an Alexa skill, I have coded several custom and default intents and they are working fine. Now I want to write a fallback intent wherein I want to get the exact statement asked/sent to Alexa skill, is there a way wherein we may get the…
NKS
  • 1,140
  • 4
  • 17
  • 35
8
votes
2 answers

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":…
Konstantin Schubert
  • 3,242
  • 1
  • 31
  • 46
7
votes
4 answers

Alexa Custom Slot Type: No value in intent

I've already posted this question to the amazon developer forum but don't receive an answer there. I guess Stackoverflow should've been the first choice from the beginning: From my understanding if I use a Custom Slot Type even if the list of its…
Korgen
  • 5,191
  • 1
  • 29
  • 43
7
votes
2 answers

Get unique device id for every amazon echo devices

I need to make a Custom Skill for the Alexa Skills Kit, which should be one echo device in every room. I need to get the device_id for every echo device. I heard this isn't possible, but maybe it changed, or if not is there any other way around.
6
votes
1 answer

Understanding slots and getting its values in Alexa Skills Kit

I am trying to understand properly how slots work programmatically. Before coding anything, I am trying to understand it well by looking at the examples for alexa sdk for python. Specifically, I was trying to understand the basics in slots in the…
Louis Storming
  • 151
  • 1
  • 10
6
votes
3 answers

Error code: InvalidIntentSamplePhraseSlot -

I got the error code Error code: InvalidIntentSamplePhraseSlot when I built the model using the new skills console. The full error message is Sample utterance "AddBookmarkIntent i am at {pageno} of {mybook}" in intent "AddBookmarkIntent" cannot…
TinyEpic
  • 541
  • 1
  • 11
  • 18
6
votes
2 answers

How do I handle 'Yes'/'No' responses from the user in Custom Skill?

I am trying to build an alexa custom skill. I am facing an issue where I am trying to get Yes/No responses from the user for a question which the skill asks the user. Alexa: Would you like to know the rules of the game? User:
emkay
  • 169
  • 2
  • 7
6
votes
4 answers

Amazon Alexa - How to create Generic Slot

How can I create a generic slot for an Alexa skill? So that I can create my own Todo app and it will recognise the free form text.
Michal Ciechan
  • 13,492
  • 11
  • 76
  • 118
5
votes
3 answers

How to return Dialog.Delegate directive to Alexa Skill model?

I want to create a simple multi-turn dialog with the Alexa Skill model. My intent consists of 3 slots, each of which are required to fulfill the intent. I prompt every slot and defined all of the needed utterances. Now I want to handle the request…
Ipsider
  • 553
  • 1
  • 7
  • 20
5
votes
1 answer

Getting Relative Time in Alexa

I'm trying to develop an Alexa skill, and I need to get the relative time, eg: "5 minutes ago". I have defined a time slot for my skill which accepts time like 5 minutes, 6.30 am or 4 in the morning. But I'm not able to accept a time like 5 minutes…
Nidhin S G
  • 1,685
  • 2
  • 15
  • 45
5
votes
2 answers

How do I create a Slot that accepts a currency amount

I want to receive a dollar amount in my utterance. So, for example, if I ask Alexa: Send $100.51 to Kroger. (pronounced, One hundred dollars and fifty one cents) I want to receive the value 100.51 in a proper slot. I have tried searching and I…
ewassef
  • 286
  • 2
  • 13
4
votes
1 answer

Alexa: Chaining Intents with Dialog.Delegate and Python

I am looking for some example code like it exists for nodejs described in this article: https://developer.amazon.com/blogs/alexa/post/9ffdbddb-948a-4eff-8408-7e210282ed38/intent-chaining-for-alexa-skill i tried to call the other intent without…
FG1994
  • 51
  • 3
4
votes
1 answer

Is it possible to pause and resume the skill programmatically?

I'm developing an Alexa skill that supports exercise training. While people are doing exercise, Alexa plays a background audio. I'm wondering if it is possible to pause training and resume later. For example, suppose the training last for 60…
randomcat
  • 413
  • 1
  • 4
  • 16
1
2 3
14 15