Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fluent Dialogs to BotBuilder #4866

Open
adriand-ghb opened this issue Mar 12, 2025 · 0 comments · May be fixed by #4864
Open

Add Fluent Dialogs to BotBuilder #4866

adriand-ghb opened this issue Mar 12, 2025 · 0 comments · May be fixed by #4864
Labels
feature-request A request for new functionality or an enhancement to an existing one. needs-triage The issue has just been created and it has not been reviewed by the team.

Comments

@adriand-ghb
Copy link

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));
@adriand-ghb adriand-ghb added feature-request A request for new functionality or an enhancement to an existing one. needs-triage The issue has just been created and it has not been reviewed by the team. labels Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for new functionality or an enhancement to an existing one. needs-triage The issue has just been created and it has not been reviewed by the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant