question

newuser-86542da4-8015-4422-8ba6-4d02f7fe19f6 avatar image
newuser-86542da4-8015-4422-8ba6-4d02f7fe19f6 asked ·

giving a string slot in Amazon alexa

Hi,

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,

  1. 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.

TypeValuesLIST_OF_CITIESHyderabad | 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

alexa skills kithow-to
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jamie Grossman avatar image
Jamie Grossman answered ·

If you're looking to build a slot type for cities, you don't need to; we have some built in ones you can use here. You could probably keep the sample utterances the same and incorporate this slot type instead for which ever region you're working with. For example, AMAZON.AT_CITY would be for cities in Austria.

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.