Socket
Socket
Sign inDemoInstall

botbuilder-dialog-loader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botbuilder-dialog-loader

A Library that helps to autload Microsoft Bot Framework dialogs


Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

botbuilder-dialog-loader

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.

Loader arguments

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. Example:

 {
    "folderA" : {
        "folderB" : {
           "some_dialogs" : [arg1, ..., argN] // A
        }
    },
    "welcome" : ["Hello", "Wolrd!"]
 }

Usage Example

  1. Create a folder - /src/dialogs;
  2. Create a file - /src/dialogs/welcome.js;
  3. Place next code into the 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);
    }
  ]);
}
  1. Create a file - /src/dialogs/askForName.js;
  2. Place next code into the askForName.js:
const botbuilder = require('botbuilder');

module.exports = function (bot) {
  bot.dialog('/askForName', [function (session) {
    botbuilder.Prompts.text(session, 'What is your name?');
  }]);
}
  1. Create 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...');

Installation

    npm install --save botbuilder-dialog-loader

Keywords

FAQs

Package last updated on 10 Jun 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc