Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
botbuilder-dialog-loader
Advanced tools
A Library that helps to autload Microsoft Bot Framework dialogs
A Library that helps to autload Microsoft Bot Framework dialogs. Autoloads dialogs from provided folder, able to pass custom arguments for dialogs. It is supposed that every javascript file in the folder will expose only function with bot as first argument. Recommendation: match dialog id's with the dialog folder structure.
Please do not hesitate to ask or publish your proposals.
So require('botbuilder-dialog-loader')
will return a function that requires next arguments:
. bot - a UniversalBot instance;
. basePath - a path to dialogs folder;
. config - (optional) a configuration object. Every object's key reflects to
a folder or to a concrete javascript file (without extension). Key's value
should contain or an object (in case of folder) or an array of arguments,
that will be passed to thefile.
{
"folderA" : {
"folderB" : {
"some_dialogs" : [arg1, ..., argN] // A
}
},
"welcome" : ["Hello", "Wolrd!"]
}
The Library will ignore any loaded file if it will not return a callback
/src/dialogs
;/src/dialogs/welcome.js
;welcome.js
:module.exports = function (bot,name) {
bot.dialog('/welcome', [function (session) {
session.send(`My name is - ${name}`)
session.beginDialog('/askForName')
},
function (session, results) {
session.endDialog(`Hi, ${results.response}!`);
setTimeout( function () {
process.exit()
},1000);
}
]);
}
/src/dialogs/askForName.js
;askForName.js
:const botbuilder = require('botbuilder');
module.exports = function (bot) {
bot.dialog('/askForName', [function (session) {
botbuilder.Prompts.text(session, 'What is your name?');
}]);
}
index.js
, a Code:const botbuilder = require('botbuilder');
const path = require('path');
const loader = require('botbuilder-dialog-loader');
let connector = new botbuilder.ConsoleConnector().listen();
let bot = new botbuilder.UniversalBot(connector);
let basePath = path.dirname(__filename) + '/src/dialogs/';
bot.dialog('/', function ( session ) {
session.beginDialog( '/welcome');
})
loader( bot, basePath, {
"welcome" : ["DialogLoader"]
});
console.log('Press any key...');
npm install --save botbuilder-dialog-loader
FAQs
A Library that helps to autload Microsoft Bot Framework dialogs
The npm package botbuilder-dialog-loader receives a total of 3 weekly downloads. As such, botbuilder-dialog-loader popularity was classified as not popular.
We found that botbuilder-dialog-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.