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;