How to edit an external JSON-file in JavaScript?
<p>I have created a little chat bot following <a href="https://github.com/esthercrawford/EstherBot" rel="noreferrer">the tutorial of Esther Crawford</a>. 
This bot check the string that enter the user and respond with one of my json answer. </p>

<p>For example if I say <em>"hello"</em> the bot 'll respond <em>"Hey, I'm so glad you set EstherBot up!"</em></p>

<p><strong>script.json</strong></p>

<pre class="lang-js prettyprint-override"><code>{
    "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."
}
</code></pre>

<p>My question is: How to edit my <strong>script.json</strong> in JavaScript?</p>

<p>For the moment when the user enters an unknown string, the bot will answer that it doesn't understand.</p>

<p><strong>script.js</strong></p>

<pre class="lang-js prettyprint-override"><code>if (!_.has(scriptRules, upperText)) {
    return bot.say('Sorry I dont understand').then(() =&gt; 'speak');
}
</code></pre>

<p>How could I get this unknown string of the user and add it in my <strong>script.json</strong> file by editing in JavaScript my JSON-file ? </p>

<p>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 <strong>script.json</strong> file, ask the user for an answer and then add this answer in the <strong>script.json</strong> file too. </p>

<p>Many thanks for your help! You'll find this project on git with the full code <a href="https://github.com/Amarog93/AlexisBot.git" rel="noreferrer">here</a>.</p>