Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
super('userProfileDialog');
let lgFile = Templates.parseFile(path.join(__dirname, "userProfileDialog.lg"));
let userProfileAdaptiveDialog = new AdaptiveDialog(ROOT_DIALOG).configure({
generator: new TemplateEngineLanguageGenerator(lgFile),
triggers: [
new OnBeginDialog([
// Ask for user's age and set it in user.userProfile scope.
new TextInput().configure(
{
// Set the output of the text input to this property in memory.
property: new StringExpression("user.userProfile.Transport"),
prompt: new ActivityTemplate("${ModeOfTransportPrompt.Text()}")
}),
new TextInput().configure(
{
property: new StringExpression("user.userProfile.Name"),
prompt: new ActivityTemplate("${AskForName()}")
}),
// SendActivity supports full language generation resolution.
// See here to learn more about language generation
// https://aka.ms/language-generation
new SendActivity("${AckName()}"),
constructor() {
super('ShowToDos');
this.triggers.push(new OnBeginDialog([
new LogAction(`ShowToDos: todos = {user.todos}`, true),
new IfCondition(`user.todos != null`, [
new SendList(`user.todos`, `Here are your todos:`)
]).else([
new SendActivity(`You have no todos.`)
])
]));
// Use parents recognizer
this.recognizer = getRecognizer();
}
}
function createChoiceInputForAllAdaptiveDialogs() {
const rootDialog = new AdaptiveDialog(AdaptiveDialog.name);
const choices = [];
const switchCases = [];
(resourceExplorer.getResources('.dialog') || []).forEach(resource => {
if (resource.resourceId !== undefined && resource.resourceId.endsWith('.main.dialog')) {
let dialogName = path.basename(resource.resourceId, '.main.dialog');
const subDialog = resourceExplorer.loadType(resource);
choices.push({value : dialogName});
switchCases.push(new Case(dialogName, [subDialog]));
}
});
rootDialog.generator = new TemplateEngineLanguageGenerator();
rootDialog.triggers.push(new OnBeginDialog([
new ChoiceInput().configure({
property: new StringExpression('turn.userChoice'),
prompt: new ActivityTemplate(`Choose a declarative sample to run..`),
style: new EnumExpression(ListStyle.list),
choices: new ArrayExpression(choices),
alwaysPrompt: new BoolExpression(true)
}),
new SendActivity("# Running ${turn.userChoice}.main.dialog"),
new SwitchCondition('turn.userChoice', switchCases),
new RepeatDialog()
]));
return rootDialog;
}