How to use the adaptive-expressions.BoolExpression function in adaptive-expressions

To help you get started, we’ve selected a few adaptive-expressions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / 05.multi-turn-prompt / dialogs / userProfileDialog.js View on Github external
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()}"),
                    new ConfirmInput().configure(
                    {
                        property: new StringExpression("turn.ageConfirmation"),
                        prompt: new ActivityTemplate("${AgeConfirmPrompt()}")
                    }),
                    new IfCondition().configure(
                    {
                        // All conditions are expressed using the common expression language.
                        // See https://aka.ms/adaptive-expressions to learn more
                        condition: new BoolExpression("turn.ageConfirmation == true"),
                        actions: [
                            new NumberInput().configure(
                            {
                                prompt: new ActivityTemplate("${AskForAge()}"),
                                property: new StringExpression("user.userProfile.Age"),
                                // Add validations
                                validations: [
                                    // Age must be greater than or equal 1
                                    "int(this.value) >= 1",
                                    // Age must be less than 150
                                    "int(this.value) < 150"
                                ],
                                invalidPrompt: new ActivityTemplate("${AskForAge.invalid()}"),
                                unrecognizedPrompt: new ActivityTemplate("${AskForAge.unRecognized()}")
                            }),
                            new SendActivity("${UserAgeReadBack()}")
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / 05.multi-turn-prompt / dialogs / userProfileDialog.js View on Github external
"int(this.value) >= 1",
                                    // Age must be less than 150
                                    "int(this.value) < 150"
                                ],
                                invalidPrompt: new ActivityTemplate("${AskForAge.invalid()}"),
                                unrecognizedPrompt: new ActivityTemplate("${AskForAge.unRecognized()}")
                            }),
                            new SendActivity("${UserAgeReadBack()}")
                        ],
                        elseActions: [
                            new SendActivity("${NoAge()}") 
                        ]
                    }),
                    new IfCondition().configure(
                    {
                        condition: new BoolExpression("turn.activity.channelId == 'msteams'"),
                        actions: [
                            // This attachment prompt example is not designed to work for Teams attachments, so skip it in this case
                            new SendActivity('Skipping attachment prompt in Teams channel...')
                        ],
                        elseActions: [
                            new AttachmentInput().configure(
                            {
                                prompt: new ActivityTemplate("${AskForImage()}"),
                                property: new StringExpression("user.userProfile.picture"),
                                validations: [
                                    "this.value.contentType == 'image/jpeg' || this.value.contentType == 'image/png'"
                                ],
                                invalidPrompt: new ActivityTemplate("${AskForImage.Invalid()}")
                            })
                        ]
                    }),
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / declarative / 60.adaptive-bot / index.js View on Github external
(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;
}