How to use the botbuilder-dialogs-adaptive.SendActivity function in botbuilder-dialogs-adaptive

To help you get started, we’ve selected a few botbuilder-dialogs-adaptive 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("${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()}")
                        ],
                        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'"
github microsoft / botbuilder-js / samples / 06. codeAction / lib / index.js View on Github external
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
github microsoft / botbuilder-js / samples / 50. todo-bot / src / clearToDos / index.ts View on Github external
constructor() {
        super('ClearToDos', [
            new LogAction(`ClearToDos: todos = {user.todos}`),
            new IfCondition(`user.todos != null`, [
                new EditArray(ArrayChangeType.clear, 'user.todos'),
                new SendActivity(`All todos removed.`)
            ]).else([
                new SendActivity(`No todos to clear.`)
            ])
        ]);

        // Use parents recognizer
        this.recognizer = getRecognizer();
    }
}
github microsoft / botbuilder-js / samples / 50. todo-bot / lib / rootDialog / index.js View on Github external
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', [
            new botbuilder_dialogs_adaptive_1.SendActivity(`Oops. An error occurred: {message}`)
        ]));
    }
}
github microsoft / botbuilder-js / samples / 50. todo-bot / lib / clearToDos / index.js View on Github external
constructor() {
        super('ClearToDos', [
            new botbuilder_dialogs_adaptive_1.LogAction(`ClearToDos: todos = {user.todos}`),
            new botbuilder_dialogs_adaptive_1.IfCondition(`user.todos != null`, [
                new botbuilder_dialogs_adaptive_1.EditArray(botbuilder_dialogs_adaptive_1.ArrayChangeType.clear, 'user.todos'),
                new botbuilder_dialogs_adaptive_1.SendActivity(`All todos removed.`)
            ]).else([
                new botbuilder_dialogs_adaptive_1.SendActivity(`No todos to clear.`)
            ])
        ]);
        // Use parents recognizer
        this.recognizer = recognizer_1.getRecognizer();
    }
}
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / 05.multi-turn-prompt / dialogs / userProfileDialog.js View on Github external
// 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()}"),
                    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
github microsoft / botbuilder-js / samples / 50. todo-bot / src / rootDialog / index.ts View on Github external
]));

        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', [
            new SendActivity(`Oops. An error occurred: {message}`)
        ]));
github microsoft / botbuilder-js / samples / 50. todo-bot / lib / rootDialog / addToDo / index.js View on Github external
constructor() {
        super('AddToDo', [
            new botbuilder_dialogs_adaptive_1.LogStep(`AddToDo: entities = {turn.entities}`, true),
            new botbuilder_dialogs_adaptive_1.SaveEntity(schema_1.variables.title, schema_1.entities.title),
            new botbuilder_dialogs_adaptive_1.TextInput(schema_1.variables.title, `What would you like to call your new todo?`),
            new botbuilder_dialogs_adaptive_1.EditArray(botbuilder_dialogs_adaptive_1.ArrayChangeType.push, schema_1.user.todoList, schema_1.variables.title),
            new botbuilder_dialogs_adaptive_1.SendActivity(`Added a todo named "${schema_1.variables.print.title}". You can delete it by saying "delete todo named ${schema_1.variables.print.title}".`),
            new botbuilder_dialogs_adaptive_1.SendActivity(`To view your todos just ask me to "show my todos".`)
        ]);
        // Use parents recognizer
        this.recognizer = recognizer_1.getRecognizer();
        // Add interruption rules
        this.addRule(new botbuilder_dialogs_adaptive_1.IntentRule(schema_1.intents.Cancel, [
            new botbuilder_dialogs_adaptive_1.CancelDialog(schema_1.events.CancelAdd)
        ]));
    }
}
github microsoft / botbuilder-js / samples / 01. sendActivity / lib / index.js View on Github external
// 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.SendActivity('Hello World!')
]));
//# sourceMappingURL=index.js.map
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / declarative / 60.adaptive-bot / index.js View on Github external
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;
}