从cloudant数据库获取数据(值)以用于诸如聊天机器人对话之类的用户输入

时间:2019-04-02 09:47:43

标签: node.js json ibm-cloud cloudant

1。是否可以在Cloudant数据库中创建销售表。

2。如何使用nodejs作为用户输入从cloudant数据库中获取数据。

例如Iam将SALES OF MOBILES出售给我的聊天机器人,那么它将在cloudant数据库中搜索并在chatbot中返回值。怎么样?

我正在尝试以下代码:

function updateMessage(input, response) { 
//var responseText = null;


if (response.intents && response.intents[0]) {
    var intent = response.intents[0];
    if (intent.intent==='Sales-1'){

      //books.get('dc746ec43a56435c6e7a06230acdb8c9',function(err,body){
        //console.log(body);
       //})

        nano.db.use('sample');
        var response= {   "selector": {
  "India": "5,564,546"
 }
}



       response.output.text="This is the modified output:"+" "+ "5,564,546";

    }
}

   return response;      

  if (response.intents && response.intents[0]) {
  var intent = response.intents[0];
 // Depending on the confidence of the response the app can return 
  different
 // messages.
  // The confidence will vary depending on how well the system is 
  trained. 
  The
 // service will always try to assign
// a class/intent to the input. If the confidence is low, then it 
 suggests
// the service is unsure of the
// user's intent . In these cases it is usually best to return a
// disambiguation message
// ('I did not understand your intent, please rephrase your question',
// etc..)

if (intent.confidence >= 0.75) {
  responseText = 'I understood your intent was ' + intent.intent;
} else if (intent.confidence >= 0.5) {
  responseText = 'I think your intent was ' + intent.intent;
} else {
  responseText = 'I did not understand your intent';
 }
}
  response.output.text = responseText;
  return response;

0 个答案:

没有答案