Find a file
2023-03-03 10:35:56 +01:00
.github/workflows Update actions 2023-02-23 15:39:55 +01:00
design V3 workflow instance viewer (#3098) 2022-05-31 20:26:45 +02:00
docker Try --platform=$BUILDPLATFORM 2022-12-30 19:42:52 +01:00
gen Update DSL and sample 2022-03-28 13:25:45 +02:00
src Fix cyclic input argument evaluation (#3755) 2023-03-02 21:21:50 +01:00
test Merge branch 'v3-composite-activity-input-evaluation-so' into v3 2023-03-03 10:35:56 +01:00
.dockerignore Add samples and docker support 2022-04-29 14:40:25 +02:00
.gitignore Implement async workflow state exporter for DB workflow instance (#3291) 2022-09-07 17:28:36 +02:00
build-and-run-all-in-one-web-docker.sh Update docker things 2022-12-30 19:29:34 +01:00
common.props Finish Azure Service Bus activities (#3617) 2023-01-12 11:59:31 +01:00
configureawait.props Update NuGet package references (#3734) 2023-02-23 14:49:46 +01:00
docker-compose.yml Elastic updates (#3623) 2023-01-13 19:10:20 +01:00
docker-run-all-in-one-web.ps1 Add samples and docker support 2022-04-29 14:40:25 +02:00
Elsa.sln Fix cyclic input argument evaluation (#3755) 2023-03-02 21:21:50 +01:00
Elsa.sln.DotSettings Use workflow definition as activity (#3654) 2023-01-28 00:36:03 +01:00
icon.png Debug 2022-12-20 12:47:41 +01:00
LICENSE Add sources from experimental repo 2022-01-04 09:42:12 +01:00
NuGet.Config Add sources from experimental repo 2022-01-04 09:42:12 +01:00
README.md Move shared test utility to common folder + various incremental changes 2022-12-20 12:13:53 +01:00

Elsa Workflows

Nuget Build status Discord Stack Overflow questions Subreddit subscribers

Elsa is a workflows library that enables workflow execution in any .NET application. Workflows can be defined in a variety of ways:

  • Using C# code
  • Using a designer
  • Using JSON
  • Using a custom DSL

Documentation

Please checkout the documentation website to get started.

Features

Here are some of the more important features offered by Elsa:

  • Execute workflows in any .NET app.
  • Supports both short-running and long-running workflows.
  • Programming model loosely inspired on WF4 (composable activities).
  • Support for complex activities such as Sequence, Flowchart and custom composite activities (which are like mini-workflows that can be used as activities).
  • Ships with a workflows designer web component (currently supports Flowchart diagrams only).

Console Examples

Hello World

The following is a simple Hello World workflow created as a console application. The workflow is created using C#.

using Elsa.Extensions;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
using Microsoft.Extensions.DependencyInjection;

// Setup service container.
var services = new ServiceCollection();

// Add Elsa services.
services.AddElsa();

// Build service container.
var serviceProvider = services.BuildServiceProvider();

// Create a workflow.
var workflow = new WriteLine("Hello World!");

// Resolve a workflow runner to run the workflow.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();

// Run the workflow.
await workflowRunner.RunAsync(workflow);

Outputs:

Hello World!

Sequential workflows

To build workflows that execute more than one step, choose an activity that can do so. For example, the Sequence activity lets us add multiple activities to execute in sequence (plumbing code left out for brevity):

// Create a workflow.
var workflow = new Sequence
{
    Activities =
    {
        new WriteLine("Hello World!"), 
        new WriteLine("Goodbye cruel world...")
    }
};

Outputs:

Hello World!
Goodbye cruel world...

Conditions

The following demonstrates a workflow where it asks the user to enter their age, and based on this, offers a beer or a soda:

// Declare a workflow variable for use in the workflow.
var ageVariable = new Variable<string>();

// Declare a workflow.
var workflow = new Sequence
{
    // Register the variable.
    Variables = { ageVariable }, 
    
    // Setup the sequence of activities to run.
    Activities =
    {
        new WriteLine("Please tell me your age:"), 
        new ReadLine(ageVariable), // Stores user input into the provided variable.,
        new If
        {
            // If aged 18 or up, beer is provided, soda otherwise.
            Condition = new Input<bool>(context => ageVariable.Get<int>(context) < 18),
            Then = new WriteLine("Enjoy your soda!"),
            Else = new WriteLine("Enjoy your beer!")
        },
        new WriteLine("Come again!")
    }
};

Notice that:

  • To capture activity output, a workflow variable (ageVariable) is used.
  • Depending on the result of the condition of the If activity, either the Then or the Else activity is executed.
  • After the If activity completes, the final WriteLine activity is executed.

ASP.NET Examples