Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}