Overview
Events are the core communication mechanism in workflows. They enable decoupled, composable workflow steps.Built-in Events
StartEvent
Initiates workflow execution:StopEvent
Terminates workflow and returns result:Custom Events
Using zodEvent
Create type-safe events with Zod schemas:Emitting Events
Event Handlers
Handle events in workflow steps:Event Flow
Error Events
Handle errors with custom error events:Event Listeners
Listen to events outside the workflow:Complex Event Patterns
Conditional Events
Parallel Events
Event Schema Validation
Zod automatically validates event data:Best Practices
- Use descriptive event names: Clear, action-oriented names
- Validate with Zod: Type-safe events prevent runtime errors
- Emit at key milestones: Track workflow progress
- Handle errors: Create error events for failures
- Document event flow: Comment event sequences
- Keep events focused: One event per logical step