elsa-workflows / elsa-workflows/elsa-core

Support Programmatic Definition of Dynamically Provided Activities

Open
#5,162 1 comment 1 reaction 0 assignees View on GitHub
elsa 3 enhancement triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

Currently, Elsa Workflows supports dynamic activity providers, enabling activities to be dynamically added to the system and utilized within the designer. However, there is a gap in functionality when it comes to using these dynamically provided activities within programmatic workflows. Unlike activities defined as .NET classes—which can be instantiated directly—the API lacks a means to incorporate dynamically provided activities into workflow classes programmatically.

## Proposed Enhancement
To bridge this gap, it's proposed to extend the workflow builder API to facilitate the definition and utilization of dynamically provided activities in programmatic workflows. This enhancement will allow for more flexible workflow definitions that can adapt to changing requirements without necessitating a recompile of the workflow classes.

### Example API Proposal
The following is a proposed API enhancement that illustrates how a developer might define a workflow programmatically using a dynamically provided activity:

```csharp
public class OrderWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
var orderId = builder.WithVariable("OrderId", null!);
var order = builder.WithVariable("Order", null);

builder.Root = new Sequence
{
Activities =
{
new ActivityInstance("Acme.DownloadOrder")
{
Inputs = new
{
OrderId = new Input(context => orderId.Get(context)!)
},
Outputs = new
{
Order = new Output(order)
}
},
}
};
}
}
```

In the example above, `"Acme.DownloadOrder"` represents an activity that is dynamically provided. This API would significantly enhance the flexibility and power of Elsa Workflows by enabling developers to programmatically define workflows that include both statically and dynamically provided activities.

### Benefit
Implementing this feature would make Elsa Workflows more versatile, supporting a wider range of workflow scenarios and integration patterns. It would empower developers to build more dynamic, adaptable workflow solutions.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the workflow builder API and the dynamic activity provider integration described in the issue, including how statically defined activities are instantiated. Done means a programmatic workflow can reference a dynamically provided activity by name and bind its inputs and outputs, with coverage for the proposed usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.