Hi everyone..I am creating a chatbot in ibm.cloud.
How to write a nodejs logic when i am chatting with chatbot the responses will come from cloudant database. Here the responses is values. That values are stored in Cloudant database.
I am trying below this code :
- function updateMessage(input, response) {
- //var responseText = null;
- if (response.intents && response.intents[0]) {
- var intent = response.intents[0];
- if (intent.intent==='Sales-1'){
- 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;
- }
Replies
Know the answer? Post it — somebody with the same question will find it here.