Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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 SetProperty('user.name', 'null'),
new TextInput('user.name', `Hi! what's your name?`),
new SendActivity(`Hi {user.name}. It's nice to meet you.`)
]));
constructor() {
super('AddToDo', [
new TextInput('$title', '@title', `What would you like to call your new todo?`),
new EditArray(ArrayChangeType.push, 'user.todos', '$title'),
new SendActivity(`Added a todo named "{$title}". You can delete it by saying "delete todo named {$title}".`),
new IfCondition(`user.tips.showToDos != true`, [
new SendActivity(`To view your todos just ask me to "show my todos".`),
new SetProperty('user.tips.showToDos', 'true')
])
]);
// Use parents recognizer
this.recognizer = getRecognizer();
// Add interruption rules
this.addRule(new OnIntent('#Cancel', [], [
new CancelAllDialogs('cancelAdd')
]));
}
}
constructor() {
super('DeleteToDo', [
new LogAction(`DeleteToDo: todos = {user.todos}`),
new IfCondition(`user.todos != null`, [
new SetProperty('$title', '@title'),
new ChoiceInput('$title', `Which todo would you like to remove?`, 'user.todos'),
new EditArray(ArrayChangeType.remove, 'user.todos', '$title'),
new SendActivity(`Deleted the todo named "{$title}".`),
new IfCondition(`user.tips.clearToDos != true`, [
new SendActivity(`You can delete all your todos by saying "delete all todos".`),
new SetProperty('user.tips.clearToDos', 'true')
])
]).else([
new SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = getRecognizer();
// Add interruption rules
this.addRule(new OnIntent('#Cancel', [], [
new CancelAllDialogs('cancelDelete')
]));
}
}
this.addRule(new OnIntent('#DeleteToDo', [], [
new DeleteToDo()
]));
this.addRule(new OnIntent('#ClearToDos', [], [
new ClearToDos()
]));
this.addRule(new OnIntent('#ShowToDos', [], [
new ShowToDos()
]));
this.addRule(new OnUnknownIntent([
new IfCondition(`user.greeted != true`, [
new SendActivity(`Hi! I'm a ToDo bot. Say "add a todo named first one" to get started.`),
new SetProperty(`user.greeted`, `true`)
]).else([
new SendActivity(`Say "add a todo named first one" to get started.`)
])
]));
// Define rules to handle cancel events
this.addRule(new OnDialogEvent('cancelAdd', [
new SendActivity(`Ok... Cancelled adding new todo.`)
]));
this.addRule(new OnDialogEvent('cancelDelete', [
new SendActivity(`Ok...`)
]));
// Define rules for handling errors
this.addRule(new OnDialogEvent('error', [
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
// 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 SetProperty('dialog.age', "'22'"),
new SwitchCondition('dialog.age', null, [
new Case("21", [
new SendActivity("age is 21!")
]),
new Case("22", [
new SendActivity("age is 22!")
])
])
]));
constructor() {
super('DeleteToDo', [
new LogAction(`DeleteToDo: todos = {user.todos}`),
new IfCondition(`user.todos != null`, [
new SetProperty('$title', '@title'),
new ChoiceInput('$title', `Which todo would you like to remove?`, 'user.todos'),
new EditArray(ArrayChangeType.remove, 'user.todos', '$title'),
new SendActivity(`Deleted the todo named "{$title}".`),
new IfCondition(`user.tips.clearToDos != true`, [
new SendActivity(`You can delete all your todos by saying "delete all todos".`),
new SetProperty('user.tips.clearToDos', 'true')
])
]).else([
new SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = getRecognizer();
// Add interruption rules
constructor() {
super('DeleteToDo', [
new botbuilder_dialogs_adaptive_1.LogAction(`DeleteToDo: todos = {user.todos}`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.todos != null`, [
new botbuilder_dialogs_adaptive_1.SetProperty('$title', '@title'),
new botbuilder_dialogs_adaptive_1.ChoiceInput('$title', `Which todo would you like to remove?`, 'user.todos'),
new botbuilder_dialogs_adaptive_1.EditArray(botbuilder_dialogs_adaptive_1.ArrayChangeType.remove, 'user.todos', '$title'),
new botbuilder_dialogs_adaptive_1.SendActivity(`Deleted the todo named "{$title}".`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.tips.clearToDos != true`, [
new botbuilder_dialogs_adaptive_1.SendActivity(`You can delete all your todos by saying "delete all todos".`),
new botbuilder_dialogs_adaptive_1.SetProperty('user.tips.clearToDos', 'true')
])
]).else([
new botbuilder_dialogs_adaptive_1.SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = recognizer_1.getRecognizer();
// Add interruption rules
this.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#Cancel', [], [
new botbuilder_dialogs_adaptive_1.CancelAllDialogs('cancelDelete')
]));
}
}
constructor() {
super('DeleteToDo', [
new botbuilder_dialogs_adaptive_1.LogAction(`DeleteToDo: todos = {user.todos}`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.todos != null`, [
new botbuilder_dialogs_adaptive_1.SetProperty('$title', '@title'),
new botbuilder_dialogs_adaptive_1.ChoiceInput('$title', `Which todo would you like to remove?`, 'user.todos'),
new botbuilder_dialogs_adaptive_1.EditArray(botbuilder_dialogs_adaptive_1.ArrayChangeType.remove, 'user.todos', '$title'),
new botbuilder_dialogs_adaptive_1.SendActivity(`Deleted the todo named "{$title}".`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.tips.clearToDos != true`, [
new botbuilder_dialogs_adaptive_1.SendActivity(`You can delete all your todos by saying "delete all todos".`),
new botbuilder_dialogs_adaptive_1.SetProperty('user.tips.clearToDos', 'true')
])
]).else([
new botbuilder_dialogs_adaptive_1.SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = recognizer_1.getRecognizer();
// Add interruption rules
this.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#Cancel', [], [
new botbuilder_dialogs_adaptive_1.CancelAllDialogs('cancelDelete')
// 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());
// 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.SetProperty('dialog.age', "'22'"),
new botbuilder_dialogs_adaptive_1.SwitchCondition('dialog.age', null, [
new case_1.Case("21", [
new botbuilder_dialogs_adaptive_1.SendActivity("age is 21!")
]),
new case_1.Case("22", [
new botbuilder_dialogs_adaptive_1.SendActivity("age is 22!")
])
])
]));
//# sourceMappingURL=index.js.map