Creating the Workflow Class
Create a new file underapp/workflows
directory. For the quickstart, we’ve created app/workflows/customer_care_workflow.py
:
Workflow Schema Components
- description: A human-readable description of what the workflow does
- event_schema: The Pydantic schema that defines the expected input data structure
- start: The name of the first node to execute in the workflow
- nodes: List of all nodes that will be part of this workflow
Registering the Workflow
To make your workflow available to the system, you need to register it in theWorkflowRegistry
.
Add a new entry to app/workflows/workflow_registry.py
:
CUSTOMER_CARE
) will be used to reference this workflow throughout the application. Choose a descriptive name that clearly indicates the workflow’s purpose.
Why Use a Registry?
TheWorkflowRegistry
enum provides several benefits:
Centralized Management
All workflows are registered in one place, making it easy to see what workflows are available in your system.Type Safety
Using an enum ensures you can only reference workflows that actually exist, preventing typos and runtime errors.Easy Discovery
IDEs can autocomplete workflow names, making development faster and reducing errors.Dynamic Loading
The system can dynamically load and execute workflows based on the registry entry. Tip: Keep your workflow names consistent with their purpose. For example, useCUSTOMER_CARE
for customer support workflows, ORDER_PROCESSING
for e-commerce workflows, etc.