Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ago. I new to Alexa and can some one help me out with this

{
  "slots": [
    {
      "name": "time",
      "type": "AMAZON.TIME"
    }
  ],
  "intent": "ReportTime"
}
like image 496
Nidhin S G Avatar asked Oct 18 '22 09:10

Nidhin S G


1 Answers

You could add a {modifier} slot that can take several keywords like "ago" and "from now". The intent could then have something like the following utterances:

{
  "name": "TimeTest",
  "samples": [
    "what happened {time} {modifier}",
    "what will happen {time} {modifier}"
  ],
  "slots": [
    {
      "name": "time",
      "type": "AMAZON.TIME",
      "samples": []
    },
    {
      "name": "modifier",
      "type": "custom_time_modifier",
      "samples": []
    }
  ]
}

with the following custom modifier type:

"types": [
{
  "name": "custom_time_modifier",
  "values": [
    {
      "id": null,
      "name": {
        "value": "ago",
        "synonyms": [
          "in the past"
        ]
      }
    },
    {
      "id": null,
      "name": {
        "value": "from now",
        "synonyms": [
          "in the future"
        ]
      }
    }
  ]
}
like image 193
Constantin Groß Avatar answered Oct 21 '22 03:10

Constantin Groß