Search code examples
alexa-skills-kitalexa-slot

giving a string slot in Amazon alexa


I'm new to alexa. I learnt and started to build a weather app.

right now I'm able to get weather data, but on the below condition,

I've craeated a custom slot(LIST_OF_CITIES) to hold Cities as below.

{
  "intents": [
    {
      "intent": "WeatherIntent",
      "slots": [
        {
          "name": "city",
          "type": "LIST_OF_CITIES"
        }
      ]
    },
    {
      "intent": "AMAZON.HelpIntent"
    },
    ]
}

and in my custom slot I gave as below.

Type               Values
LIST_OF_CITIES     Hyderabad | pune | london

and below are my Utterances

WeatherIntent give me {city} climate
WeatherIntent {city}
WeatherIntent what's the climate in {city}
WeatherIntent what's the weather in {city}
WeatherIntent {city}

when I run my program using any of the three cities mentioned in the above table, I'm able to get the correct. If I use anything apart from the above, it is sending back value as -4.

If I want to get tempreature of some other city, I need to add that city in the slot list.

Please let me know how can I get the vaues dynamically, I mean with out depending on the LIST_OF_CITIES, If I enter a city name, it should send back the result.

Also I tried adding type as LITERAL and also as AMAZON.LITERAL. When I saved it, I get the exception as

Error: There was a problem with your request: Unknown slot name '{city}'. Occurred in sample 'WeatherIntent get me weather of {city}' on line 1.
Please let me know where am I going wrong and how can I fix this.

Thanks


Solution

  • Amazon provides some default list Slot Types for cities or even regions. E.g.

    • AMAZON.US_CITY
    • AMAZON.AT_CITY
    • AMAZON.DE_REGION
    • ...

    You can use these as type when defining your custom slot.