Getting Started
This guide will walk you through creating your first Serverless Workflow. You’ll learn how to define a simple workflow that calls an HTTP service, processes data, and produces output.Before you begin, ensure you have a Serverless Workflow runtime installed, or use one of the available SDKs to validate and test your workflow.
Prerequisites
- Basic understanding of YAML or JSON
- A text editor or IDE
- A Serverless Workflow runtime (optional for validation)
Create Your First Workflow
Define the Workflow Document
Every workflow begins with a document section that provides metadata about your workflow:The document section includes:
dsl: The version of the Serverless Workflow DSLnamespace: A logical grouping for your workflowsname: A unique identifier for your workflowversion: Semantic version of your workflowtitleandsummary: Human-readable documentation
Define Input and Output
Configure how your workflow receives and returns data:
Input validation ensures your workflow receives data in the expected format. If validation fails, the workflow will fault with a validation error.
Add Your First Task
Tasks are the fundamental computing units of a workflow. Let’s add a simple This task uses a runtime expression
set task to create a greeting:${ .name } to access the input data and create a personalized greeting.The Serverless Workflow DSL supports runtime expressions for dynamic data manipulation. By default, expressions use the
jq language and must be enclosed in ${ } when in strict mode.Call an External Service
Let’s extend the workflow to call an HTTP service. Add a The
call task:call task invokes external services using protocols like HTTP, gRPC, OpenAPI, and more.Transform Output
Use the output section to shape your workflow’s final result:The
output.as expression transforms the workflow’s data before returning it to the caller.Understanding Task Flow
In Serverless Workflow, tasks execute in sequence by default:- The workflow begins with the first task defined
- Once a task completes, the next task executes
- Tasks can explicitly control flow using the
thenproperty - The workflow ends when the last task completes or when a task explicitly ends execution
Task Types Available
The Serverless Workflow DSL provides several built-in task types:Call
Invoke external services and functions via HTTP, gRPC, OpenAPI, and more
Set
Dynamically set or modify workflow data during execution
For
Iterate over collections and perform tasks for each item
Switch
Execute different paths based on conditions
Wait
Pause execution for a specified duration
Listen
Wait for and react to specific events
Emit
Publish events to external systems
Run
Execute containers, scripts, shell commands, or nested workflows
Adding Error Handling
Make your workflow fault-tolerant by adding error handling:try task attempts to execute a task and handles errors gracefully, allowing the workflow to continue without interruption.
Next Steps
Core Concepts
Deep dive into workflows, tasks, events, and data flow
DSL Reference
Complete reference for all workflow definitions and properties
Examples
Explore practical examples demonstrating specific features
Task Types
Learn about all available task types and their configurations
Additional Resources
- Community Slack Channel - #serverless-workflow
- GitHub Repository
- CNCF Serverless Working Group