沃森会话服务提醒编码 [英] Reminder codings in Watson Conversation Service

查看:109
本文介绍了沃森会话服务提醒编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用watson会话服务制作食物到期日chatbot。因此,当特定的食物到期日期接近时,主要功能会很警觉,这意味着我必须同时保存食物和预期食物的持续时间。 (牛奶 - 例如14天,或者蛋 - 7天)



这是有人回答我提出的问题的代码。

  function updateMessage(input,data,req,res){
if(data.context.verifiedDate){
searchRequest (data,req,res);
} else if(data.output& data.output.text){
return res.json(data);
}
返回数据;
}

函数searchRequest(data,req,res){
//要做的事情并返回值
var sendRequest =感谢您的等待,请求是+ valueRequest;
data.output.text [0] = sendRequest;
返回数据;


* Date.prototype.addDays = function(days){
var dat = new Date(this.valueOf());
dat.setDate(dat.getDate()+ days);
返回dat;
}
var dat = new Date();
alert(dat.addDays(7))*

像我以前说过的单独处理食物。但根据这个规范,我认为它只允许一种食物提醒。
1.您如何编写代码来单独提醒食物?
2.addDay编码是否与上面的代码一起工作('updateMessage')。因为在行之间读取它似乎没有连接(如具有相同的变量/功能左右)来实现它。

*请注意,我从头开始,所以我可能会在理解JS中的术语或函数时遇到一些麻烦。

解决方案

我认为您可以将产品的日子与产品结合在一起...



您需要创建一个上下文变量并保存产品的名称......或者创建一个包含所有产品的实体并保存在一个上下文变量中,如:

 context:{
product:<?@product?>
},

像:

 函数searchRequest(data,req,res){
if(data.context.verifiedDate&& data.context.product == ='milk'){
var sendRequest =感谢您等待,验证产品为14天,产品:+ data.context.product;
返回数据;
} else if(data.context.verifiedDate&& amp; data.context.product ==='egg'){
var sendRequest =感谢您等待,产品的验证期为7天,product ::+ data.context.product;
data.output.text [0] = sendRequest;
返回数据;
}
}


I am making a food expiry date chatbot using watson conversation service. So the main function would be alert when the specific food due date is near, which means I have to save both food and the expected days the food would last. (Milk - 14 days, or egg- 7 days, for instance)

And this is the code someone answered for me with the previous questions I asked.

function updateMessage(input, data, req, res) {
if (data.context.verifiedDate){
searchRequest(data, req, res);
} else if (data.output && data.output.text) {
  return res.json(data);
}
return data;
}

function searchRequest(data, req, res){
// something to do and return value
var sendRequest = "Thanks for wait, the request is" + valueRequest;
data.output.text[0] = sendRequest;
return data;
}

*Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf());
dat.setDate(dat.getDate() + days);
return dat;
}
var dat = new Date();
alert(dat.addDays(7))*

Like I've said I have to deal with foods individually. But according to this code I think it only allows one food to alert. 1. How do you write codes to alert food individually? 2. And does "addDay" coding works with the code above ('updateMessage'). Because reading between the lines it doesn't seem to have connections (like having same variables/functions or so) to implement it.

*Note that I started from scratch, so I might have some trouble understanding terms or functions in JS.

解决方案

I think you can combine the days with the product...

You will need to create one context variable and save the name of your product... Or create one entity with all products and save within one context variable, like:

"context": {
       "product": "<? @product ?>"
 },

Like:

function searchRequest(data, req, res){
   if(data.context.verifiedDate && data.context.product === 'milk'){
       var sendRequest = "Thanks for wait, , the validate for the product is 14 days, product: " + data.context.product;
       return data;
   } else if(data.context.verifiedDate && data.context.product === 'egg'){
       var sendRequest = "Thanks for wait, the validate for the product is 7 days, product::" + data.context.product;
       data.output.text[0] = sendRequest;
       return data;
   }
}

这篇关于沃森会话服务提醒编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆