This sample demonstrates how to build interactive workflows that request user input during execution using the Question, RequestExternalInput, and WaitForInput actions.
- Using
Questionto prompt for user responses - Using
RequestExternalInputto request external data - Using
WaitForInputto pause and wait for input - Processing user responses to drive workflow decisions
- Interactive conversation patterns
workflow.yaml- The declarative workflow definitionmain.py- Python script that loads and runs the workflow with simulated user interaction
-
Ensure you have the package installed:
cd python pip install -e packages/agent-framework-declarative -
Run the sample:
python main.py
The workflow demonstrates a simple survey/questionnaire pattern:
- Greeting: Sends a welcome message
- Question 1: Asks for the user's name
- Question 2: Asks how they're feeling today
- Processing: Stores responses and provides personalized feedback
- Summary: Summarizes the collected information
The main.py script shows how to handle ExternalInputRequest to provide responses during workflow execution.
When a human-in-loop action is executed, the workflow yields an ExternalInputRequest containing:
variable: The variable path where the response should be storedprompt: The question or prompt text for the user
The workflow runner should:
- Detect
ExternalInputRequestin the event stream - Display the prompt to the user
- Collect the response
- Resume the workflow (in a real implementation, using external loop patterns)
For more complex scenarios where external processing is needed, the workflow can yield an ExternalLoopEvent that signals the runner to pause and wait for external input.