I have created a little chat bot following the tutorial of Esther Crawford. This bot check the string that enter the user and respond with one of my json answer.
For example if I say "hello" the bot 'll respond "Hey, I'm so glad you set EstherBot up!"
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?
For the moment when the user enters an unknown string, the bot will answer that it doesn't understand.
script.js
if (!_.has(scriptRules, upperText)) {
return bot.say('Sorry I dont understand').then(() => 'speak');
}
How could I get this unknown string of the user and add it in my script.json file by editing in JavaScript my JSON-file ?
I want that my bot learn by itself, if he doesn't know the answer it should automatically add the question of the user to the script.json file, ask the user for an answer and then add this answer in the script.json file too.
Many thanks for your help! You'll find this project on git with the full code here.