Skip to main content

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

  1. Use descriptive event names: Clear, action-oriented names
  2. Validate with Zod: Type-safe events prevent runtime errors
  3. Emit at key milestones: Track workflow progress
  4. Handle errors: Create error events for failures
  5. Document event flow: Comment event sequences
  6. Keep events focused: One event per logical step

See Also