Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bot.rootDialog = dialogs;
//=================================================================================================
// Rules
//=================================================================================================
dialogs.recognizer = new RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new OnIntent('#JokeIntent', [], [
new BeginDialog('TellJokeDialog')
]));
// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
new BeginDialog('AskNameDialog')
]));
//=================================================================================================
// Child Dialogs
//=================================================================================================
const askNameDialog = new AdaptiveDialog('AskNameDialog', [
new IfCondition('user.name == null', [
new TextInput('user.name', `Hi! what's your name?`)
]),
new SendActivity(`Hi {user.name}. It's nice to meet you.`),
new EndDialog()
]);
dialogs.actions.push(askNameDialog);
server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async (context) => {
// Route activity to bot.
await bot.onTurn(context);
});
});
// Initialize bots root dialog
const dialogs = new botbuilder_dialogs_adaptive_1.AdaptiveDialog();
bot.rootDialog = dialogs;
//=================================================================================================
// Rules
//=================================================================================================
dialogs.recognizer = new botbuilder_dialogs_adaptive_1.RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#JokeIntent', [], [
new botbuilder_dialogs_adaptive_1.BeginDialog('TellJokeDialog')
]));
// Handle unknown intents
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
new botbuilder_dialogs_adaptive_1.BeginDialog('AskNameDialog')
]));
//=================================================================================================
// Child Dialogs
//=================================================================================================
const askNameDialog = new botbuilder_dialogs_adaptive_1.AdaptiveDialog('AskNameDialog', [
new botbuilder_dialogs_adaptive_1.IfCondition('user.name == null', [
new botbuilder_dialogs_adaptive_1.TextInput('user.name', `Hi! what's your name?`)
]),
new botbuilder_dialogs_adaptive_1.SendActivity(`Hi {user.name}. It's nice to meet you.`),
new botbuilder_dialogs_adaptive_1.EndDialog()
]);
dialogs.actions.push(askNameDialog);
});
});
// Initialize bots root dialog
const dialogs = new AdaptiveDialog();
bot.rootDialog = dialogs;
//=================================================================================================
// Rules
//=================================================================================================
dialogs.recognizer = new RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new OnIntent('#JokeIntent', [], [
new BeginDialog('TellJokeDialog')
]));
// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
new BeginDialog('AskNameDialog')
]));
//=================================================================================================
// Child Dialogs
//=================================================================================================
const askNameDialog = new AdaptiveDialog('AskNameDialog', [
new IfCondition('user.name == null', [
new TextInput('user.name', `Hi! what's your name?`)
]),
});
});
// Initialize bots root dialog
const dialogs = new botbuilder_dialogs_adaptive_1.AdaptiveDialog();
bot.rootDialog = dialogs;
//=================================================================================================
// Rules
//=================================================================================================
dialogs.recognizer = new botbuilder_dialogs_adaptive_1.RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#JokeIntent', [], [
new botbuilder_dialogs_adaptive_1.BeginDialog('TellJokeDialog')
]));
// Handle unknown intents
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
new botbuilder_dialogs_adaptive_1.BeginDialog('AskNameDialog')
]));
//=================================================================================================
// Child Dialogs
//=================================================================================================
const askNameDialog = new botbuilder_dialogs_adaptive_1.AdaptiveDialog('AskNameDialog', [
new botbuilder_dialogs_adaptive_1.IfCondition('user.name == null', [
new botbuilder_dialogs_adaptive_1.TextInput('user.name', `Hi! what's your name?`)
]),
new botbuilder_dialogs_adaptive_1.SendActivity(`Hi {user.name}. It's nice to meet you.`),
new botbuilder_dialogs_adaptive_1.EndDialog()
]);
dialogs.actions.push(askNameDialog);
const tellJokeDialog = new botbuilder_dialogs_adaptive_1.AdaptiveDialog('TellJokeDialog', [
new botbuilder_dialogs_adaptive_1.SendActivity(`Why did the 🐔 cross the 🛣️?`),
new botbuilder_dialogs_adaptive_1.EndTurn(),
new botbuilder_dialogs_adaptive_1.SendActivity(`To get to the other side...`),