Include the library in your .html
file
<script src="https://zhiftydk.github.io/chatbot/chatbot.js"></script>
Example: How to train your neural network from intents
const bot = new chatBot("./intents.json");
bot.train();
Example: How to train your neural network from new intents untop of your current model
const bot = new chatBot("./intents.json", "./model.json");
bot.train(); // When training is done model.json file will be downloaded
Example: How to run your model after training
const bot = new chatBot("./intents.json", "./model.json");
bot.run("Hello there!").then((response) => {
console.log(response); //Greeting response
});
Create intents.json
file and format the intents like this:
{
"intents": [
{
"tag": "greeting",
"trigger": false,
"patterns": [
"Hi",
"Hey",
"How are you",
"Is anyone there?",
"Hello",
"Good day"
],
"responses": [
"Hey :-)",
"Hello, thanks for visiting",
"Hi there, what can I do for you?",
"Hi there, how can I help?"
]
},
]
}