Skip to content

Add Fluent Dialogs to BotBuilder #4866

Open
@adriand-ghb

Description

@adriand-ghb

Is your feature request related to a problem? Please describe.
While the WaterfallDialog can be used to implement arbitrarily complex user interactions, common things such as branching decision trees and loops eventually result in a complex, hard to review and manage, sequence of callbacks and sub-dialogs.

Describe the solution you'd like
This feature request proposes the addition of a FluentDialog class to the microsoft/botbuilder-js repository. The FluentDialog uses event sourcing to handle complex user interactions in bot applications, providing an uninterrupted execution flow similar to the durable function orchestrator pattern.

Rationale:
The addition of fluent dialogs will significantly enhance the developer experience by:

  1. Simplified Dialog Implementation: The FluentDialog provides a straightforward way to define complex conversation flows using JavaScript's generator functions, making the implementation more intuitive and reducing boilerplate code.
  2. Event Sourcing: Developers can focus on defining the dialog flow without worrying about state persistence, as the event sourcing mechanism handles it transparently. This is similar to the durable function orchestrator pattern, where the execution history is maintained, allowing the function to resume from where it left off.
  3. Improved Developer Experience: The design allows for asynchronous operations and state management to be handled seamlessly, making it easier to build sophisticated bot interactions.

Describe alternatives you've considered
I couldn't find any alternative other than the WaterFallDialog I already mentioned.

Additional context
The usage would be something along the lines of the dialogFlow function shown below:

// Initialize a DialogSet, passing in a property used to capture state.
const storage = new MemoryStorage();
const convoState = new ConversationState(storage);
const dialogState = convoState.createProperty('dialogState');
const dialogs = new DialogSet(dialogState);

// Implement the dialog flow function. This example shows a simple Q&A like interaction 
function *dialogFlow(context) {

    let response = yield context.prompt(DIALOG_PROMPT, 'say something');
    yield context.sendActivity(`you said: ${response}`);
        
    let shouldContinue = yield context.prompt(CONFIRM_PROMPT, 'play another round?', ['yes', 'no'])
    if (shouldContinue) {
        yield context.restart();
    }

    yield context.sendActivity('good bye!');
}

const MAIN_DIALOG = 'MAIN_DIALOG';
const TEXT_PROMPT = 'TEXT_PROMPT'
const CONFIRM_PROMPT = 'CONFIRM_PROMPT'

// Add a dialog. Use the included FluentDialog type, initialized with the dialog flow function
dialogs.add(new FluentDialog(MAIN_DIALOG, dialogFlow));
dialogs.add(new TextPrompt(DIALOG_PROMPT));
dialogs.add(new ConfirmPrompt(CONFIRM_PROMPT));

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA request for new functionality or an enhancement to an existing one.needs-triageThe issue has just been created and it has not been reviewed by the team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions