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 e
You can't save in a file using client-side script, you have to use some server-side scripting like PHP, NodeJS etc. to save something in a file.
For example in NodeJS you can use the fs library:
fs = require('fs');
var m = JSON.parse(fs.readFileSync('fileName.json').toString());
m.forEach(function(p){
p.name= m.name;
});
fs.writeFile('fileName.json', JSON.stringify(m));
Hope it helps