Java有Alexa的自定义技能要求缺少插槽

Java有Alexa的自定义技能要求缺少插槽

问题描述:

我目前正在为Java中的Alexa构建一个自定义技能。Java有Alexa的自定义技能要求缺少插槽

我希望Alexa使用现有的Exchange Server设置约会。

对于约会,我希望Alexa检查是否有姓名,日期和时间由用户给出。我可能会使用if语句如下:if(date.getValue()== NULL){ 回报askResponse( “请给一个日期,以创建约会”)

会发生什么是Alexa的

要求丢失的插槽,但当我回答技能只是退出。我不知道如何让Alexa认出我的回应。

代码如下:

public SpeechletResponse getTerminResponse(Slot name, Slot date, Slot time, Session session, IntentRequest request) throws Exception { 

    if(time.getValue() == null) { 
      return askResponse("Please insert time"); 
     } else if (date.getValue() == null) { 
      return askResponse("Please insert date"); 
     } else if (name.getValue() == null) { 
      return askResponse("Please insert name"); 
     } else { 

      try { 

       String[] datumArray = date.getValue().split("-"); 
       String[] zeitArray = time.getValue().split(":"); 

       Date startDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0])), (Integer.parseInt(zeitArray[1])), 0); 
       Date endDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0]))+1, (Integer.parseInt(zeitArray[1])), 0); 

       System.out.println(startDatum.toString()); 
       System.out.println(endDatum.toString()); 
       ExchangeHelper eh = new ExchangeHelper(); 
       eh.createMeeting(name.getValue(), "Test", startDate, endDate); 

       return getTellSpeechletResponse("Appointment created successfully");  

      } catch (Exception e) { 
       System.out.println(e); 
       return askResponse("Failed to create appointment"); 
      } 
     } 
} 

这里是我的Interaction Model

任何帮助,将不胜感激,因为我一直在研究文档和例子了几天,我只是无法得到它的工作。

问候

+0

你可以把你的交互模型在开发者平台上做了吗? (交互模式,自定义插槽,话语) –

+0

@TaísBellini我编辑了我原来的帖子,因为我不知道如何添加图片到评论。请原谅德国的意图和插槽,Datum意味着日期,Zeit意味着时间和名称是自我解释我猜;) – MCR

+0

好吧,这个界面对我来说是新的。您可以将提示“请插入时间”等直接放在该技能构建器中,不需要输入代码。是你做的吗?如果您点击插槽,您应该看到“提示”字段,然后它会为您处理。我现在猜测的是,既然你在代码中对待它,你的话语就不会指望单个插槽响应作为条目,所以它会因为没有匹配而关闭。 –

你可以给getTellSpeechletResponse的代码? 根据你附加的图片,你正在使用“新”对话框模型,以便亚马逊收集你意图的所有插槽。 https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/dialog-interface-reference#directives

最大的可能是你忘了发回DelegateDirective(通过speechletResponse.setDirectives(...))亚马逊告诉Alexa的照顾,收集槽值。但是,只有您发送代码才能解决此问题。我也想看到一个亚马逊的对话Java的例子,但还没有找到。

如果您正在使用此对话模型,则您也不需要if elses,因为alexa可以自行识别哪些插槽已丢失。您必须在交互模型中标记为“是否需要此插槽来满足意图”。比你也不需要创建自己的问答反应,而只是为了给你的4个时隙在交互模型中提供话语。