I created a small chatbot following the instructions of Esther Crawford . This bot checks the string entered by the user and responds with one of my json answers.
For example, if I say hi, the bot will reply: "Hey, I'm so glad you set up EstherBot!"
script.json
{ "HELLO": "Hey, I'm so glad you set EstherBot up!", "I LOVE YOU": "Awh, shucks! I love you too!", "CONNECT ME": "", "DISCONNECT": "Roger that, EstherBot is back." }
My question is: how to edit my script.json in JavaScript?
At that moment, when the user enters an unknown string, the bot will reply that he does not understand.
script.js
if (!_.has(scriptRules, upperText)) { return bot.say('Sorry I dont understand').then(() => 'speak'); }
How can I get this unknown user string and add it to my script.json file by editing my JSON file in JSON?
I want my bot to learn it myself, if it does not know the answer, it should automatically add the user question to the script.json file, ask the user for an answer, and then add this answer to the script.json file . also.
Thank you very much for your help! You will find this Git project with full code here .
source share