Scenario

The scenario feature allows you to systematically manage and reuse complex dialog flows. You can group multi-step dialogs or conditional flows into a single logical unit.

Basic Object Style#

The simplest and most intuitive way is to define a scenario as an object:

Each step can be called as a method, and since it returns a Promise, you can execute them sequentially using await.

Separated Style (Advanced)#

You can separate control logic and implementation to construct more complex scenarios:

This approach separates business logic from UI implementation, improving maintainability.

Passing Parameters#

You can implement dynamic behavior by passing parameters to scenario steps:

Handling User Input#

You can receive user input and pass it to the next step or process it:

API Reference#

Main Scenario API methods:

  • scenario.step(name, params): Execute a specific step
  • scenario.run(paramsMap): Execute all steps sequentially
  • scenario.getSteps(): Return list of steps
  • scenario.hasStep(name): Check if step exists
  • scenario.clone(newName): Clone scenario
Scenario - Managing Complex Dialog Flows | ilokesto - React Library Collection