Skip to main content
This section provides real-world examples demonstrating various features and capabilities of the Serverless Workflow specification. Each example is designed to illustrate specific concepts and patterns you can use in your own workflows.

Example Categories

Basic Workflows

Learn the fundamental building blocks of serverless workflows:
  • Task Execution - Sequential and parallel task execution patterns
  • Data Manipulation - Setting and transforming workflow data
  • Control Flow - Conditional logic, loops, and branching
  • Subworkflows - Composing workflows from reusable components
View Basic Workflow Examples →

Event-Driven Workflows

Explore event-driven patterns and reactive workflows:
  • Event Listeners - Waiting for and consuming events
  • Event Emission - Publishing events from workflows
  • Event Correlation - Correlating multiple events together
  • Scheduled Workflows - Cron-based and event-triggered scheduling
View Event-Driven Examples →

Service Orchestration

Integrate with external services and APIs:
  • HTTP/REST APIs - Calling REST endpoints with various configurations
  • OpenAPI Integration - Type-safe API calls using OpenAPI specifications
  • gRPC Services - Invoking gRPC methods
  • AsyncAPI - Publishing and subscribing to message brokers
  • Authentication - OAuth2, OIDC, Bearer token, and other auth methods
View Service Orchestration Examples →

Error Handling

Implement robust error handling and recovery strategies:
  • Try-Catch Blocks - Catching and handling errors gracefully
  • Retry Logic - Automatic retry with backoff strategies
  • Error Raising - Explicitly raising errors with context
  • Conditional Error Handling - Different recovery paths based on error types
View Error Handling Examples →

Quick Reference

Common Task Types

Task TypePurposeExample File
call: httpMake HTTP requestsdo-single.yaml
call: openapiInvoke OpenAPI operationscall-openapi.yaml
call: grpcCall gRPC methodscall-grpc.yaml
call: asyncapiPublish/subscribe messagescall-asyncapi-publish.yaml
listenWait for eventslisten-to-one.yaml
emitPublish eventsemit.yaml
setSet workflow dataset.yaml
forIterate over collectionsfor.yaml
forkExecute tasks in parallelfork.yaml
switchConditional branchingswitch-then-string.yaml
try/catchError handlingtry-catch.yaml
run: containerExecute containersrun-container.yaml
run: workflowCall subworkflowsrun-subflow.yaml
waitDelay executionwait-duration-iso8601.yaml

Workflow Scheduling

Schedule TypeDescriptionExample
cronTime-based schedulingschedule-cron.yaml
on: oneTriggered by single eventschedule-event-driven.yaml
on: allTriggered when all events receivedlisten-to-all.yaml

Example Structure

All examples follow the Serverless Workflow DSL 1.0.3 specification and include:
document:
  dsl: '1.0.3'          # DSL version
  namespace: examples    # Workflow namespace
  name: workflow-name    # Unique workflow name
  version: '0.1.0'      # Workflow version

# Optional: Define input schema
input:
  schema:
    format: json
    document:
      type: object
      properties:
        # ... schema definition

# Optional: Schedule configuration
schedule:
  cron: '0 0 * * *'     # or event-based trigger

# Main workflow logic
do:
  - taskName:
      # Task definition

# Optional: Timeout configuration
timeout:
  after:
    seconds: 30

Using These Examples

Running Examples

To run any example workflow:
  1. Ensure you have a Serverless Workflow runtime installed
  2. Copy the example YAML file
  3. Modify any placeholders (URLs, credentials, etc.)
  4. Execute using your runtime’s CLI or API

Adapting Examples

Each example is designed to be:
  • Self-contained - Complete, runnable workflow definitions
  • Documented - Clear explanations of what each part does
  • Adaptable - Easy to modify for your specific use case
  • Best-practice - Following recommended patterns and conventions

Additional Resources

Contributing Examples

Have a useful workflow pattern to share? Contributions are welcome!
  • Submit examples via pull request
  • Follow the existing example structure
  • Include clear documentation
  • Test examples before submitting

Build docs developers (and LLMs) love