I am having 5 different categories of dialogs. I wanted to keep each of them in seperate files like - Dialog1.js, Dialog2.js, and so on.
Could some one help me on the same?
I am having 5 different categories of dialogs. I wanted to keep each of them in seperate files like - Dialog1.js, Dialog2.js, and so on.
Could some one help me on the same?
There are many ways to achieve this. Here we are creating dialogs in some different files, but registering the dialogs with bot by importing them to index.js and calling bot.dialog("<dialog name>", <dialog>)
. You can build on this to have many dialogs registered with bot.
This keeps the dialog code short and separate.
dialog1.js
const dialog1 = [function(session){
session.send("this is dialog 1");
}];
module.exports = {
dialog: dialog1
}
dialog2.js
const dialog2 = [function(session){
session.send("this is dialog 2");
}];
module.exports = {
dialog: dialog2
}
index.js
const dialog1 = require("./dialog1.js").dialog;
const dialog2 = require("./dialog2.js").dialog;
....
bot.dialog("dialog1", dialog1);
bot.dialog("dialog2", dialog2);