AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Design and code for database chatbot
 
 

Hello everybody.
I’m making a chatbot based on Facebook’s Messenger platform. It’s written in Nodejs. After following the tutorial, I’ve built a basic chatbot that can work with if..else if statements. And to deloy it with Heroku. But my teacher, want me to put all user questions and answers into a file and upload that file to the server. .
I have created a txt file as attach but I do not know how to write code to analyze it. Long can anyone help me, thanks a lot !!!

File Attachments
keyword.txt  (File Size: 1KB - Downloads: 59)
 

 
  [ # 1 ]

Help me , please !

 

 
  [ # 2 ]

Load the text file,

How much tuition?
About $50
Around fifty dollars

How are you
?
I am fine,tks !

You are beautiful!
Thank you very much!
So are you

What day is today
?
Today,Monday 
Tomorrow Tuesday
I am not sure about today 

... into an array:

var script [
[
"HOW MUCH TUITION",
"About $50",
"Around fifty dollars",
],
[
"HOW ARE YOU",
"I am fine,tks !",
],
[
"YOU ARE BEAUTIFUL",
"Thank you very much!",
"So are you",
],
[
"WHAT DAY IS TODAY",
"Today,Monday ",
"Tomorrow Tuesday",
"I am not sure about today",
],
];

console.log(script[0][0]);  // How much tuition? 

The first element (uppercase) in the array is always key zero and always the “Q” which is matched.
And the remaining elements are 1,2,3, etc count can vary in the array and they are always the “R” list.
You can randomly pick one from the “R” list for a response.

Please note: This code is hand coded in a text editor and is not tested at all, and it is not complete, so it is just for discussion and learning purposes.  As a Node.JS programmer, you should be inspired from this pseudo code.

 

 

 

 

 
  login or register to react