如何排除周日从沃森谈话

我在编码和沃森谈话新手,我试图做一个chatbot安排星期一到星期六约会。 我使用@ sys-date实体,它工作正常,但我不知道如何排除星期日。例如:

沃森 :什么是你最好的日子?
用户 :星期天
华生 :在这一天build立closures

我在工作区尝试:(condition)if: action =='sunday'like this: workspace

并在nodejs中这样编码

// Send the input to the conversation service conversation.message(payload, function (err, data) { if (err) { return res.status(err.code || 500).json(err) }else if(data.output.action==='sunday'){ var date = new Date(); if(!(date.getDay() % 6)){ return res.json(payload,data.output.text["On this day the establishment is closed"]); }}else{ return res.json(updateMessage(payload, data)); }});}); 

它仍然给我星期天date(例如23/04/2017)。 我知道一切都是错误的,但我真的试过了..请有人帮助我吗? 我会很感激,如果你可以把代码来帮助我..

在这种情况下,是的…您可以使用参数data与Watson和用户发送消息。 而且,你不能从系统实体中排除“星期天”。 这个权利只是为了帮助我们特殊的条件。

在你的情况下,使用:

 data.output.text[0] = "On this day the establishment is closed"; 

因为data.output.text将Watson消息发送给对话。

但是,对于一个好的聊天机器人来说,一个最好的实践是创buildIntentsEntities来为你的机器人传递智能 ,并在你的聊天机器人中保留尽可能多的智能。 而你的应用程序只会检查。

例如,创build一个Entitie @days ,其值为Sunday, Monday等。

  • 用例子创build一个intent如何问“安排约会”
  • 创build一个Entitie @days ,星期天,星期一等。
  • 在意图和实体条件下(#bestDay和@days)在对话框中创build一个stream程。

在你的高级JSON中,添加一个上下文variables,像这样:

  { "context": { "day": "<? @days ?>" }, "output": { "text": { "values": [ "Sorry. On $day the establishment is closed" ], "selection_policy": "sequential" } } } 

检查stream程:

在这里输入图像描述

检查stream程正常工作:

在这里输入图像描述

如果不是星期天:

在这里输入图像描述

下载工作区以帮助您在这里更多。