Workflow Definitions
Our Docs modernization effort is underway. New documentation will co-exist alongside our current docs content. We're rebuilding the docs for better organization and engagement so you can find what you need to know with clear unambiguous communication.
- This page has not been reviewed for SEO
- This page contains re-used elements with some rewording and restructuring
- This page probably does not belong in this section.
A Workflow Definition is code that defines how a Workflow functions. You write your definitions in your preferred programming languages using Temporal's suite of SDKs. A Workflow Definition (sometimes referred to as a Workflow Function) encompasses the end-to-end series of steps of a Temporal application. It has one entry point and takes a custom payload as input. Depending on the programming language, the Workflow Definition is typically a function or object method.
Supported development languages
Below are different ways to develop a basic Workflow Definition using our existing SDKs. Although it's possible to use an unsupported language to develop a Temporal application we advise against it. It's much harder and you'll have fewer resources to call on in our community.
- Go
- Java
- PHP
- Python
- Typescript
- .NET
func YourBasicWorkflow(ctx workflow.Context) error {
// ...
return nil
}
Workflow Definition in Java (Interface)
// Workflow interface
@WorkflowInterface
public interface YourBasicWorkflow {
@WorkflowMethod
String workflowMethod(Arguments args);
}
Workflow Definition in Java (Implementation)
// Workflow implementation
public class YourBasicWorkflowImpl implements YourBasicWorkflow {
// ...
}
Workflow Definition in PHP (Interface)
#[WorkflowInterface]
interface YourBasicWorkflow {
#[WorkflowMethod]
public function workflowMethod(Arguments args);
}
Workflow Definition in PHP (Implementation)
class YourBasicWorkflowImpl implements YourBasicWorkflow {
// ...
}
@workflow.defn
class YourWorkflow:
@workflow.run
async def YourBasicWorkflow(self, input: str) -> str:
# ...
Workflow Definition in Typescript
type BasicWorkflowArgs = {
param: string;
};
export async function WorkflowExample(
args: BasicWorkflowArgs,
): Promise<{ result: string }> {
// ...
}
Workflow Definition in C# and .NET
[Workflow]
public class YourBasicWorkflow {
[WorkflowRun]
public async Task<string> workflowExample(string param) {
// ...
}
}
Developer guides
Our Temporal SDK developer guides provide comprehensive overviews of the structures, primitives, and features used in your Temporal Application Workflow Definition development. Here are links to each of the guides and their API references:
- Go SDK developer guide and API reference
- Java SDK developer guide and API reference
- PHP SDK developer guide and API reference
- Python SDK developer guide and API reference
- TypeScript SDK developer guide and API reference
- .NET SDK developer guide and API reference
Hands on Workflow Definition learning
To learn more about creating Workflows Definitions, visit our courses. Each course provides guided introductions to many of these elements with an expert instructor:
- Temporal 101: Introducing the Temporal Platform
- Temporal 102: Exploring Durable Execution
- Versioning Workflows
- Interacting with Workflows
Additional community support
Reach out to others in our Temporal community to learn and grow as a developer:
- Temporal Community Forums
- Temporal Community Slack
- Temporal YouTube channel
- Temporal Community Events
In practice, a Workflow Definition and a Workflow Function are basically the same thing. If you dive deeper, you'll uncover the nuanced distinctions between the two:
- A Workflow Definition refers to the code source managed by a Workflow Execution. A Workflow Execution is a complete process, which runs from start to completion. The Workflow Definition runs once per execution.
- A Workflow Function refers to the source for the instance of a Workflow Function Execution. Temporal may invoke a Workflow Function Execution more than once during the lifetime of a Workflow Execution, normally during replays.