ElsaScript and BPMN workflow formats
ElsaScript and BPMN provide two source formats for describing workflows. ElsaScript is a concise Elsa-native language that becomes an executable workflow, while BPMN is an interchange format that lets Elsa import process diagrams and export the original document when it is still valid. These formats connect authoring, workflow loading, and workflow management without making either source format the same as the runtime activity graph. See authoring and expressions, expression languages, and workflow management for related system context.
ElsaScript DSL
Source language
ElsaScript is a text language for declaring a workflow with named activities, values, variables, control flow, listeners, and flowchart links. A source file can also set workflow metadata such as its display name, definition identity, version, and use of an expression language. The language supports both a named workflow form and a short form of activity statements that become a default workflow. References: src/…/ElsaScriptParser.cs• L149-193, src/…/ElsaScriptParser.cs• L303-421, src/…/ElsaScriptParser.cs• L428-534, test/…/ParserTests.cs• L158-217
Workflow materialization
Materialization is the step that turns ElsaScript source into an Elsa workflow that the rest of the system can manage and run. The compiler resolves activity names through the activity registry, maps source arguments to activity inputs, and builds the matching sequence, branch, loop, or flowchart structure. Expressions remain Elsa expressions with a selected language, so the DSL can use the expression system described in expression languages. References: src/…/ElsaScriptCompiler.cs• L31-111, src/…/ElsaScriptCompiler.cs• L139-155, src/…/ElsaScriptCompiler.cs• L168-227, src/…/ElsaScriptCompiler.cs• L361-452
Definition identity
The ElsaScript materializer uses the source stored on a workflow definition and then restores the definition identity and version managed by Elsa. This keeps the executable workflow aligned with the definition selected by workflow management instead of letting source metadata replace the store’s identity. References: src/…/ElsaScriptWorkflowMaterializer.cs• L8-35, src/…/MaterializedWorkflow.cs• L5-13
Blob-backed ElsaScript loading
Storage provider
The blob-backed workflow provider discovers workflow source files in a configured blob store and turns accepted files into materialized workflows. It scans nested paths, filters by extensions declared by format handlers, and lets each handler decide whether it can read a file. This separates storage access from format knowledge, so ElsaScript support can share the provider with other workflow formats. References: src/…/BlobStorageWorkflowsProvider.cs• L9-16, src/…/BlobStorageWorkflowsProvider.cs• L33-68, src/…/IBlobWorkflowFormatHandler.cs• L7-42
ElsaScript file handling
The ElsaScript blob handler treats .elsa files as workflow source. It compiles the file, identifies the result as supplied by the FluentStorage provider and ElsaScript materializer, and keeps the original text for later source-aware operations. A file that cannot be parsed or compiled is logged and skipped so one bad source file does not stop the provider from loading the other files. References: src/…/ElsaScriptBlobWorkflowFormatHandler.cs• L10-19, src/…/ElsaScriptBlobWorkflowFormatHandler.cs• L22-59, src/…/MaterializedWorkflow.cs• L8-13
Feature composition
Blob-backed ElsaScript support depends on both the blob workflow provider and the ElsaScript DSL. Enabling the combined feature adds the ElsaScript format handler to the provider, while enabling ElsaScript alone only adds parsing, compilation, and materialization services. References: src/…/ElsaScriptBlobStorageFeature.cs• L12-24, src/…/ElsaScriptFeature.cs• L12-34, src/…/BlobStorageFeature.cs• L15-40
BPMN interchange
Import analysis
BPMN import accepts BPMN 2.0 XML and converts a selected process into an Elsa workflow whose root is a BPMN process scope. Analysis provides a read-only preview of the findings from the same read path used by import, so the preview and the later import describe the same source. A document with several processes requires the caller to choose one. References: src/…/BpmnInterchangeDocumentService.cs• L111-166, src/…/Endpoint.cs• L9-50, src/…/Endpoint.cs• L11-85
The import path checks whether the deployment can run the BPMN features used by the document before it stores the workflow. It then binds BPMN work to Elsa activities. BPMN constructs with known Elsa behavior can map directly, while a task whose work is not defined by BPMN needs an Elsa activity binding in the document. References: src/…/BpmnInterchangeDocumentService.cs• L117-166, src/…/BpmnWorkBinder.cs• L13-18, src/…/BpmnWorkBinder.cs• L59-152
Elsa activity bindings
An Elsa activity binding is an elsa:activityBinding vendor extension placed inside the BPMN element that needs Elsa-specific work. It names the Elsa activity type and carries its configured inputs. This makes the BPMN document self-contained for Elsa import, but it also means the document can disclose input values and expressions that are part of the workflow’s behavior. References: src/…/BpmnActivityBindingFormat.cs• L11-25, src/…/BpmnActivityBindingFormat.cs• L68-106
The binding format uses Elsa’s activity serialization rules for input values. Import rejects missing activity types, unknown inputs, duplicate inputs, and malformed input data instead of creating a workflow that can only fail later. References: src/…/BpmnActivityBindingFormat.cs• L180-256, src/…/BpmnWorkBinder.cs• L138-169
Export preservation
BPMN export writes the BPMN source retained during import rather than rebuilding a new BPMN document from the current Elsa activity graph. The read-and-write path preserves BPMN layout data and foreign content that the interchange library retained, which supports round trips with documents produced by other BPMN tools. References: src/…/BpmnInterchangeDocumentService.cs• L26-55, src/…/BpmnInterchangeDocumentService.cs• L169-182, test/…/BpmnInterchangeDocumentServiceTests.cs• L77-105
Export is available only when the definition still carries its original BPMN source and the source was recorded for the current definition version. A later edit does not update the retained BPMN document, so the system refuses to export missing or stale source instead of returning a document that does not represent the current definition. References: src/…/BpmnInterchangeDocumentService.cs• L184-228, src/…/Endpoint.cs• L13-79
Interchange lifecycle
The BPMN interchange lifecycle connects preview, import, execution, and export through the source document and its bound workflow definition. The main path is:
- Analyze the BPMN document without saving it.
- Select a process when the document contains more than one.
- Check host capabilities and bind BPMN work to Elsa activities.
- Save the bound workflow definition together with source information needed for a safe export.
- Export the retained source only while it still matches the stored definition version.
The following diagram shows how a BPMN document moves through this lifecycle.
flowchart LR
A[BPMN 2.0 document] --> B[Analyze]
A --> C[Read and select process]
C --> D[Check capabilities]
D --> E[Bind BPMN work to Elsa activities]
E --> F[Store workflow definition and source]
F --> G[Run workflow]
F --> H{Source present and current?}
H -->|Yes| I[Export BPMN 2.0 document]
H -->|No| J[Refuse export]
References: src/…/BpmnInterchangeDocumentService.cs• L16-65 src/…/BpmnInterchangeDocumentService.cs• L131-166 src/…/BpmnInterchangeDocumentService.cs• L195-228
Format relationships
Authoring roles
ElsaScript is suited to writing an Elsa-native workflow as source text. BPMN is suited to exchanging a process model with BPMN tools while carrying the Elsa activity bindings needed for execution in Elsa. Both formats must resolve to activities and expressions that the target application supports, but they preserve different source forms and have different export expectations.
| Format | Main role | Source of executable workflow | Source preservation |
|---|---|---|---|
| ElsaScript | Elsa-native authoring and file-based loading | ElsaScript compiler and materializer | Original source is retained when loaded from blob storage |
| BPMN 2.0 | Process interchange and diagram round trips | BPMN reader plus Elsa activity binding | Original BPMN XML is retained and exported only while current |
References: src/…/ElsaScriptWorkflowMaterializer.cs• L8-35 src/…/ElsaScriptBlobWorkflowFormatHandler.cs• L34-46 src/…/BpmnInterchangeDocumentService.cs• L26-55
Runtime boundary
Neither format runs by itself. Each format produces or loads a workflow definition that depends on the application’s activity registry, expression support, and runtime capabilities. This boundary lets workflow management handle identity and lifecycle while the format-specific systems handle source interpretation and interchange rules.
References: src/…/ElsaScriptCompiler.cs• L168-187 src/…/BpmnInterchangeDocumentService.cs• L57-65 src/…/BpmnFeature.cs• L10-25
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to ElsaScript activity names, argument rules, or expression aliases must stay aligned with the activity registry and the expression language names accepted by the compiler.
- Changes to the
.elsaextension or blob handler registration must preserve the provider’s extension filtering and the materializer name stored inMaterializedWorkflow. - Changes to BPMN binding element names, namespace values, or input serialization affect every existing exported document and any external tool that reads the
elsa:extension. - Changes to BPMN source custom properties must preserve the link between retained source and the workflow definition version, or export can return stale process data.
- Changes to BPMN task binding rules must update both import-time binding and publish-time validation so edits after import cannot remove the activity that a process needs.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| ElsaScript contains an unknown activity or invalid syntax | Direct compilation fails. A blob-backed file is skipped and logged. | Keep source activity names registered and treat provider logs as the signal for skipped files. |
A .elsa file is stored without the ElsaScript blob feature | The blob provider has no handler for the format, so the workflow is not loaded. | Enable the combined blob and ElsaScript feature. |
| BPMN task has no usable Elsa activity binding | Import is rejected because the process has work that BPMN does not define. | Add an elsa:activityBinding for the task or remove the task. |
| BPMN binding names an uninstalled activity or input that the activity does not expose | Import is rejected instead of creating a workflow with missing work or configuration. | Install the activity module and keep binding input names in sync with the activity contract. |
| BPMN document needs a host capability that the deployment does not declare | Import is rejected before the definition is stored. | Deploy the required BPMN runtime capability or change the process model. |
| Retained BPMN source is removed or the definition version changes after import | BPMN export is refused because the source cannot be trusted as a representation of the current definition. | Preserve the source metadata and re-import the BPMN document after a source-level change. |
Key files
| File | Why to read it |
|---|---|
| src/…/ElsaScriptParser.cs | Defines the high-level ElsaScript forms that can represent a workflow. |
| src/…/ElsaScriptCompiler.cs | Shows how source concepts become an Elsa workflow and how activities and expressions are resolved. |
| src/…/ElsaScriptWorkflowMaterializer.cs | Connects stored ElsaScript source to workflow definition identity. |
| src/…/BlobStorageWorkflowsProvider.cs | Explains the storage-to-format-handler loading flow. |
| src/…/ElsaScriptBlobWorkflowFormatHandler.cs | Shows the ElsaScript-specific blob boundary and source retention. |
| src/…/BpmnInterchangeDocumentService.cs | Owns the shared analyze, import, source retention, and export lifecycle. |
| src/…/BpmnWorkBinder.cs | Explains how BPMN work becomes an Elsa process scope and activities. |
| src/…/BpmnActivityBindingFormat.cs | Defines the Elsa vendor extension that makes BPMN tasks executable in Elsa. |
| src/…/Endpoint.cs and src/…/Endpoint.cs | Shows the external import and export boundaries. |