获得Alexa的相对时间

Nid*_*S G 5 alexa alexa-skill alexa-skills-kit alexa-slot

我正在尝试开发Alexa技能,我需要获得相对时间,例如:" 5分钟前 ".

我为我的技能定义了一个时间段,接受时间5 minutes,6.30 am或者4 in the morning.但是我无法接受这样的时间5 minutes ago.我是Alexa的新手,可以帮助我解决这个问题

{
  "slots": [
    {
      "name": "time",
      "type": "AMAZON.TIME"
    }
  ],
  "intent": "ReportTime"
}
Run Code Online (Sandbox Code Playgroud)

Con*_*roß 3

您可以添加一个{modifier}可以容纳多个关键字(例如“过去”和“从现在开始”)的插槽。那么意图可以有类似以下的话语:

{
  "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": []
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

具有以下自定义修饰符类型:

"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"
        ]
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)