Kanak Sharma
Kanak Sharma

Reputation: 11

How to execute programmatic workflows in Elsa Workflow

I have programmatically created Workflow Json say Pipe1, I want to know how I can execute it like other workflows that we create using Elsa Dashboard by clicking on execute button. Usually, it hits URL like /WorkflowName/execute, but this is not working in case of programmatic workflows (the ones that we create using JSON file).

I want to know how I can programmatically execute my custom workflow (created using JSON file) using some API endpoint.

Upvotes: 1

Views: 1241

Answers (1)

Sipke Schoorstra
Sipke Schoorstra

Reputation: 3419

You can execute any workflow via the REST API, even workflows created in code or using JSON.

However, these workflows need to be available from the workflow registry. If your JSON workflows are provided via a workflow provider (any IWorkflowProvider implementation like BlobStorageWorkflowProvider), then they will be part of the workflow registry.

For example, if you store workflow JSON files in your application in a folder called workflows, you can configure the blob storage provider like this:

// Configure blob storage for blob storage workflow storage provider. 
services.Configure<BlobStorageWorkflowProviderOptions>(options => options.BlobStorageFactory = () => StorageFactory.Blobs.DirectoryFiles(Path.Combine(_environment.ContentRootPath, "Workflows")));

You can find the sample application here: https://github.com/elsa-workflows/elsa-core/tree/master/src/samples/aspnet/Elsa.Samples.SignalApi

Upvotes: 0

Related Questions