Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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(),
// Create bots DialogManager and bind to state storage
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
bot.userState = new botbuilder_1.UserState(new botbuilder_1.MemoryStorage());
// Listen for incoming activities.
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;
// Handle unknown intents
dialogs.triggers.push(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
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.`)
]));
//# sourceMappingURL=index.js.map
bot.conversationState = new ConversationState(new MemoryStorage());
// Listen for incoming activities.
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 AdaptiveDialog();
bot.rootDialog = dialogs;
// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
new InitProperty('dialog.list', 'array'),
new TextInput("dialog.item", "What is your name?"),
new EditArray(ArrayChangeType.push, 'dialog.list', 'dialog.item'),
new SendActivity('Your name in an array: {dialog.list}')
]));
// Create bots DialogManager and bind to state storage
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
bot.userState = new botbuilder_1.UserState(new botbuilder_1.MemoryStorage());
// Listen for incoming activities.
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;
// Handle unknown intents
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
new botbuilder_dialogs_adaptive_1.SetProperty('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.`)
]));
//# sourceMappingURL=index.js.map
// Bind to production/development recognizer
this.recognizer = recognizer_1.getRecognizer();
// Handle recognized intents
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnIntent('#AddToDo', [], [
new addToDo_1.AddToDo()
]));
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnIntent('#DeleteToDo', [], [
new deleteToDo_1.DeleteToDo()
]));
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnIntent('#ClearToDos', [], [
new clearToDos_1.ClearToDos()
]));
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnIntent('#ShowToDos', [], [
new showToDos_1.ShowToDos()
]));
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
new botbuilder_dialogs_adaptive_1.IfCondition(`user.greeted != true`, [
new botbuilder_dialogs_adaptive_1.SendActivity(`Hi! I'm a ToDo bot. Say "add a todo named first one" to get started.`),
new botbuilder_dialogs_adaptive_1.SetProperty(`user.greeted`, `true`)
]).else([
new botbuilder_dialogs_adaptive_1.SendActivity(`Say "add a todo named first one" to get started.`)
])
]));
// Define rules to handle cancel events
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnDialogEvent('cancelAdd', [
new botbuilder_dialogs_adaptive_1.SendActivity(`Ok... Cancelled adding new todo.`)
]));
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnDialogEvent('cancelDelete', [
new botbuilder_dialogs_adaptive_1.SendActivity(`Ok...`)
]));
// Define rules for handling errors
this.triggers.push(new botbuilder_dialogs_adaptive_1.OnDialogEvent('error', [
bot.userState = new UserState(new MemoryStorage());
// Listen for incoming activities.
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 AdaptiveDialog();
bot.rootDialog = dialogs;
// Add a default rule for handling incoming messages
dialogs.addRule(new OnUnknownIntent([
new CodeAction(async (dc) => {
const count = dc.state.getValue('conversation.count') || 0;
dc.state.setValue('conversation.count', count + 1);
return await dc.endDialog();
}),
new SendActivity('{conversation.count}')
]));
bot.userState = new UserState(new MemoryStorage());
// Listen for incoming activities.
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 AdaptiveDialog();
bot.rootDialog = dialogs;
// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
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.`)
]));
// Create bots DialogManager and bind to state storage
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
bot.userState = new botbuilder_1.UserState(new botbuilder_1.MemoryStorage());
// Listen for incoming activities.
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;
// Add a default rule for handling incoming messages
dialogs.triggers.push(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
new botbuilder_dialogs_adaptive_1.CodeAction(async (dc) => {
const count = dc.state.getValue('conversation.count') || 0;
dc.state.setValue('conversation.count', count + 1);
return await dc.endDialog();
}),
new botbuilder_dialogs_adaptive_1.SendActivity('{conversation.count}')
]));
//# sourceMappingURL=index.js.map
// Initialize bots root dialog
const dialogs = new AdaptiveDialog();
bot.rootDialog = dialogs;
// Create recognizer
dialogs.recognizer = new RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new OnIntent('#JokeIntent', [], [
new SendActivity(`Why did the 🐔 cross the 🛣️?`),
new EndTurn(),
new SendActivity(`To get to the other side...`)
]));
// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
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.`)
]));
bot.conversationState = new ConversationState(new MemoryStorage());
// Listen for incoming activities.
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 AdaptiveDialog();
bot.rootDialog = dialogs;
// Handle unknown intents
dialogs.triggers.push(new OnUnknownIntent([
new TextInput("dialog.name", "what is your name?"),
new TraceActivity(null, "memory", "dialog"),
]));