Search code examples
alexa-skills-kitalexa-slot

AMAZON.TIME issue in Alexa Skill


{
  "intents": [
    {
      "name": ... // my current intent name
      "slots": [
        {
          "name": "StartTime",
          "type": "AMAZON.TIME"
        },
        {
          "name": "EndTime",
          "type": "AMAZON.TIME"
        }
      ]
    }
  ]
}

I'm using AMAZON.TIME slot type for time slots. The problem is that in one of my slots, Alexa cannot handle data properly. Details - When I said "1pm" in EndTime slot, Alexa knew it was "13:00". But, in StartTime slot, it only returned "00:00", sometimes didn't return any response. I did every step exactly the same on both slots.


Solution

  • Since you're typing the text in Alexa Simulator, Alexa is unable to parse your text properly and thus it is not recognizing your Start time and End time.

    In Alexa Simulator, try using by voice, there's a mic image - Press and hold it -> Then tell your response -> then release the mic image. This will solve the issue.

    Why this strange behavior?

    Let's see an example: Say you're working on a weather app and want to know the weather of London between 10 AM and 2 PM. So in Simulator you type:

    Tell me the weather in London between 10 AM and 2 PM

    Now, when you say the above response but now in voice, Alexa will interpret it as:

    Tell me the weather in London between ten am and two pm

    According to AMAZON.TIME docs, ten am will become 10:00 and two pm will become 14:00. But your typing text 10 AM is little strange to AMAZON.TIME and thus it doesn't recognize it properly.

    To make this 10 AM working, you'll need to define your own custom slot and then work on it on your code manually. But, when in production, end users will call your app using voice, so when user says 10 AM, Alexa will send ten am as slot value to your app and your app may break. So I don't recommend this method.

    Alexa is built using/for voice experience, so testing it with voice utterances makes more sense than just typing.