Skip to content

Instantly share code, notes, and snippets.

@alexzaitsev
Last active August 1, 2017 08:50
Show Gist options
  • Save alexzaitsev/5f0ab5a9d201e5e6438b098c57677d28 to your computer and use it in GitHub Desktop.
Save alexzaitsev/5f0ab5a9d201e5e6438b098c57677d28 to your computer and use it in GitHub Desktop.
How To Write Reusable and Testable Code with Microsoft Bot Framework
const bot = new builder.UniversalBot(connector);
bot.dialog(‘/’, [
(session, args, next) => {
if (session.userData.languageSet) {
next();
} else {
session.beginDialog(‘welcome:/pickLocale’);
}
},
...
]);
bot.library(require('./dialogs/welcome'));
@mpicciolli
Copy link

Hi

A little mistake in your code :
session.beginDialog(‘welcome:/pickLocale’);

Replace by
session.beginDialog(‘welcome:pickLocale’);

To invoke dialogs within your library bots will need to call session.beginDialog() with a fully qualified dialog id in the form of ':'. You'll typically hide this from the devloper by exposing a function from their module that starts the dialog for them. So calling something like myLib.someDialog(session, { arg: '' }); would end up calling session.beginDialog('myLib:someDialog', args); under the covers.

Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment