How to use the botbuilder-dialogs-adaptive.IfCondition 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-js / samples / 30. stateMachineDialog / src / index.ts View on Github external
// ringing state
const ringing = dialogs.addState('ringing', [
    new SendActivity(`☎️ ring... ring...`),
    new ConfirmInput('$answer', `Would you like to answer it?`, true),
    new IfCondition('$answer == true', [
        new EmitEvent('callConnected')
    ])
]);
ringing.permit('callConnected', 'connected');


// connected state
const connected = dialogs.addState('connected', [
    new SendActivity(`📞 talk... talk... talk... ☹️`),
    new ConfirmInput('$hangup', `Heard enough yet?`, true),
    new IfCondition('$hangup == true', [
        new EmitEvent('callEnded')
    ])
]);
connected.permit('callEnded', 'offHook');
github microsoft / botbuilder-js / samples / 50. todo-bot / src / addToDo / index.ts View on Github external
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')
        ]));
    }
}
github microsoft / botbuilder-js / samples / 50. todo-bot / src / rootDialog / index.ts View on Github external
]));

        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...`)
        ]));
github microsoft / botbuilder-js / samples / 04. onIntent / src / index.ts View on Github external
const dialogs = new AdaptiveDialog();
bot.rootDialog = dialogs;

// Create recognizer
dialogs.recognizer = new RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);

// Tell the user a joke
dialogs.addRule(new OnIntent('#JokeIntent', [], [
    new SendActivity(`Why did the 🐔 cross the 🛣️?`),
    new EndTurn(),
    new SendActivity(`To get to the other side...`)
]));

// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
    new IfCondition('user.name == null', [
        new TextInput('user.name', `Hi! what's your name?`)
    ]),
    new SendActivity(`Hi {user.name}. It's nice to meet you.`)
]));
github microsoft / botbuilder-js / samples / 05. beginDialog / src / index.ts View on Github external
dialogs.addRule(new OnIntent('#JokeIntent', [], [
    new BeginDialog('TellJokeDialog')
]));

// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
    new BeginDialog('AskNameDialog')
]));


//=================================================================================================
// Child Dialogs
//=================================================================================================

const askNameDialog = new AdaptiveDialog('AskNameDialog', [
    new IfCondition('user.name == null', [
        new TextInput('user.name', `Hi! what's your name?`)
    ]),
    new SendActivity(`Hi {user.name}. It's nice to meet you.`),
    new EndDialog()
]);
dialogs.actions.push(askNameDialog);

const tellJokeDialog = new AdaptiveDialog('TellJokeDialog',[
    new SendActivity(`Why did the 🐔 cross the 🛣️?`),
    new EndTurn(),
    new SendActivity(`To get to the other side...`),
    new EndDialog()
]);
dialogs.actions.push(tellJokeDialog);
github microsoft / botbuilder-js / samples / 50. todo-bot / src / deleteToDo / index.ts View on Github external
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();
github microsoft / botbuilder-js / samples / 50. todo-bot / src / deleteToDo / index.ts View on Github external
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')
        ]));
    }
github microsoft / botbuilder-js / samples / 50. todo-bot / lib / showToDos / index.js View on Github external
constructor() {
        super('ShowToDos', [
            new botbuilder_dialogs_adaptive_1.LogAction(`ShowToDos: todos = {user.todos}`, true),
            new botbuilder_dialogs_adaptive_1.IfCondition(`user.todos != null`, [
                new botbuilder_dialogs_adaptive_1.SendList(`user.todos`, `Here are your todos:`)
            ]).else([
                new botbuilder_dialogs_adaptive_1.SendActivity(`You have no todos.`)
            ])
        ]);
        // Use parents recognizer
        this.recognizer = recognizer_1.getRecognizer();
    }
}
github microsoft / botbuilder-js / samples / 03. ifCondition / lib / index.js View on Github external
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.triggers.push(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
    new botbuilder_dialogs_adaptive_1.IfCondition('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
github microsoft / botbuilder-js / samples / 05. beginDialog / lib / index.js View on Github external
// Rules
//=================================================================================================
dialogs.recognizer = new botbuilder_dialogs_adaptive_1.RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#JokeIntent', [], [
    new botbuilder_dialogs_adaptive_1.BeginDialog('TellJokeDialog')
]));
// Handle unknown intents
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
    new botbuilder_dialogs_adaptive_1.BeginDialog('AskNameDialog')
]));
//=================================================================================================
// Child Dialogs
//=================================================================================================
const askNameDialog = new botbuilder_dialogs_adaptive_1.AdaptiveDialog('AskNameDialog', [
    new botbuilder_dialogs_adaptive_1.IfCondition('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.`),
    new botbuilder_dialogs_adaptive_1.EndDialog()
]);
dialogs.actions.push(askNameDialog);
const tellJokeDialog = new botbuilder_dialogs_adaptive_1.AdaptiveDialog('TellJokeDialog', [
    new botbuilder_dialogs_adaptive_1.SendActivity(`Why did the 🐔 cross the 🛣️?`),
    new botbuilder_dialogs_adaptive_1.EndTurn(),
    new botbuilder_dialogs_adaptive_1.SendActivity(`To get to the other side...`),
    new botbuilder_dialogs_adaptive_1.EndDialog()
]);
dialogs.actions.push(tellJokeDialog);
//# sourceMappingURL=index.js.map