Skip to main content

Building Workflows

In Conductor, all workflow definitions are stored as JSON. There are three ways to create a Conductor workflow:

  1. Workflow as code—Using the Conductor SDKs, define the workflow in your preferred language (Python, Java, JavaScript, C#, Go, Clojure) and register it to the Conductor server. Once registered, the JSON workflow definition is generated and saved.
  2. Workflow as JSON—Write the workflow in JSON and register it to the Conductor server using the /api/metadata/workflow endpoint.
  3. Visual workflow editor—Using Orkes Platform, define your workflow visually, which is formatted as JSON under the hood.

Static vs dynamic workflows

With Conductor, you can create workflows statically (ahead of time) or dynamically (at runtime).

Dynamic workflows are created using the workflow as code approach, allowing you to write your workflow and task workers in your preferred language and execute it immediately. This is useful in cases where workflows cannot be defined ahead of time, as the number of tasks and flow control depend on real-time factors.

To learn more about creating dynamic workflows, refer to the SDKs: Python, Java, JavaScript, C#, Go, and Clojure.

Tasks in workflows

A workflow definition consists of a collection of tasks and operators and specifies the order and execution of the defined tasks. Conductor provides a set of system tasks and operators, but you can also write your own custom worker tasks.

For control flow

The control structures and operations in your Conductor workflow are implemented as tasks. Here are the tasks available for managing the flow of execution:

  • Conditional flow
    • Switch—Execute tasks conditionally, like an if…else… statement.
  • Looping flow
    • Do While—Execute tasks repeatedly, like a do…while… statement.
  • Parallel flows
    • Fork—Execute a static number of tasks in parallel.
    • Dynamic Fork—Execute a dynamic number of tasks in parallel.
    • Join—Join the forks after a Fork or Dynamic Fork before proceeding to the next task.
    • Start Workflow—Asynchronously start another workflow.
  • Jumps or state changes in flow
    • Terminate—Terminate the current workflow, like a return statement.
    • Sub Workflow—Synchronously start another workflow, like a subroutine.
    • Terminate Workflow—Terminate another ongoing workflow.
    • Update Task—Update the status of another ongoing task.
  • State querying
    • Get Workflow—Get the execution details of another ongoing workflow.
  • Waits in flow
    • Wait—Pause the current workflow until a set time, duration, or signal is received.
    • Wait for Webhook—Pause the current workflow for an incoming webhook signal.
    • Human–Pause the current workflow for user input before proceeding to the next task.
  • Dynamic tasks in flow
    • Dynamic—Execute a task dynamically, like a function pointer.

For assigning variables

In general, variables are bounded within each task and passed along in the workflow as necessary. However, you can also handle variables or secrets at a global environment or workflow level.

For execution logic

In most common cases, you can make use of existing Conductor features instead of creating a custom worker from scratch. These include tasks for data transformation, user journeys, and LLM chaining.

Use CaseTask to Use
Call an API or HTTP endpointHTTP
Poll an API or HTTP endpointHTTP Poll
Publish or consume eventsEvent
Clean or transform JSON dataJSON JQ
Modify SQL databasesJDBC
Execute JavaScript scriptsInline
Evaluate and retrieve data in spreadsheetsBusiness Rule
Get authorized using a signed JWTGet Signed JWT
Orchestrate human input in the loopHuman
Query data from Conductor Search API or MetricsQuery Processor
Send alerts to OpsgenieOpsgenie
Retrieve text or JSON content from a URLGet Document
Generate text embeddingsGenerate Embeddings
Store text embeddings in a vector databaseStore Embeddings
Generate and store text embeddings in a vector databaseIndex Text
Chunk, generate, and store text embeddings in a vector databaseIndex Document
Retrieve data from a vector databaseGet Embeddings
Retrieve data from a vector database based on a search querySearch Index
Generate text from an LLM based on a defined promptText Complete
Generate text from an LLM based on a user query and additional system/assistant instructionsChat Complete

Task definitions

All system or custom tasks can be registered to the Conductor server as a task definition. For custom tasks, this is a must to do before the task can be used in a workflow.

All task definitions are also stored as JSON. It specifies general implementation details, like expected task input and output keys, as well as failure-handling configurations, like rate limits, retries, and timeouts. These parameters can be updated in real time without needing to redeploy your application.

For more information on how to configure a task’s failure-handling policy, refer to Error Handling.

Task configuration

The task configuration is part of the workflow definition. It specifies the workflow-specific implementation details, like the task reference name, task type, task input parameters, and so on.

Although each task type has its own unique configuration, all tasks share several parameters in common.

Common configuration parameters

ParameterDescriptionRequired/ Optional
nameName of the task. The default value is the same as the task type.

The name can be changed to something descriptive. To use a given task definition, the task name here must match the task definition name (case-sensitive).
Required.
taskReferenceNameReference name for the task.

Must be a unique value in a given workflow.
Required.
typeThe task type. For example, HTTP, SIMPLE.Required.
inputParametersMap of the task’s input parameters.Depends on task type.
optionalWhether the task is optional.

If set to true, the workflow continues to the next task even if this task fails or remains incomplete.
Optional.
asyncCompleteWhether the task is completed asynchronously. The default value is false. Supported values:
  • false—Task status is set to COMPLETED upon successful execution.
  • true—Task status is kept as IN_PROGRESS until an external event completes it.
Optional.
startDelayThe time in seconds to wait before making the task available for worker polling. The default value is 0.Optional.
onStateChangeConfiguration for publishing an event or starting another task when this task status changes.Optional.

Task-specific configuration parameters

Refer to the Task Reference to learn more about the task configuration for each task type.

Passing data between tasks

Data can be passed from one task to another by using dynamic inputs in a task’s inputParameters. In Conductor, dynamic inputs are formatted as JSONPath expressions. To learn more about using dynamic variables, refer to Dynamic Task Inputs.

Task reuse

Since task workers typically perform a unit of work as part of a larger workflow, Conductor’s infrastructure is built to enable task reusability out of the box. Once a task is defined in Conductor, it can be reused numerous times:

  • In the same workflow, using different task reference names.
  • Across various workflows.

When reusing tasks, it's important to think of situations that a multi-tenant system faces. By default, all the work assigned to this worker goes into the same task queue. This could result in your worker not being polled quickly if there is a noisy neighbor in the ecosystem. You can tackle this situation by scaling up the number of workers to handle the task load, or even using task-to-domain to route the task load into separate queues.

Workflow parameters

The workflow definition contains configuration parameters that define the workflow behaviour, such as the list of task configuration, the workflow inputs and outputs, and the workflow failure policies.

ParameterDescriptionRequired/ Optional
nameWorkflow name.
  • For v4.0.1 and prior: Only letters, digits, hyphens (-), and underscores (_) are allowed.
  • For v4.0.2 and later: Only letters, digits, spaces, hyphens (-), underscores (_), and certain special characters (<, >, {, }, #) are allowed.
Required.
description​Workflow description.Required.
versionWorkflow version.Required.
tasksArray of task configuration objects.Required.
inputParametersArray of workflow input keys.Optional.
outputParametersJSON template used to generate the workflow output.

If unspecified, the workflow output will be the output of the last executed task.
Optional.
schemaVersionVersion of Conductor’s JSON format. Must be 2.Required.
restartableWhether the workflow is allowed to restart. The default value is true.

Set to false if restarting a completed workflow causes side effects.
Optional.
workflowStatusListenerEnabledWhether to enable a workflow status listener. The default value is false.Optional.
ownerEmailThe email ID of the workflow creator.Required.
timeoutPolicyThe workflow timeout policy.Optional.
timeoutSecondsThe timeout, in seconds, after which the workflow will be set as TIMED_OUT if it hasn't reached a terminal state.

Set to 0 for no timeouts.
Optional.
failureWorkflowThe compensation flow upon workflow failure. Useful for cleanup, notifications, or post actions.Optional.

More on configuring workflow parameters

Refer to these topics to learn more: