BPMN Process Engine
BpmnProcessEngine offers a lightweight BPMN execution/simulation layer that runs inside Flow, tracking token activity, honoring start/service/task/gateway semantics, and exposing pause/resume/terminate controllers. It is designed for demos, debugging, or hooking into AI/automation systems.
Capabilities
- Token-based execution with event callbacks so you can drive timelines, logs, or dashboards
- Customizable task executor and variable evaluator to plug in backend calls or business logic
- Lifecycle helpers (
pause,resume,terminate) for building interactive simulations or training flows
Main APIs
| API | Description |
|---|---|
loadProcess(nodes, edges) | Loads Flow nodes/edges (typically from bpmnXmlToFlow) into the engine |
createInstance(initialVariables?) | Creates a process instance with tokens, variables, and meta |
start(instanceId) | Starts the instance and moves tokens along the graph |
pause(instanceId) / resume(instanceId) | Pause / resume execution for demos |
terminate(instanceId) | Forcefully stops an instance |
setVariable(instanceId, key, value) | Update runtime variables for conditional gateways |
getVariable(instanceId, key) | Read the current value of a variable |
getInstance(instanceId) / getAllInstances() | Inspect instance state, node map, history |
Example
The demo below loads a sample BPMN, starts an instance, pauses/resumes/terminates it, and shows event logs from the engine.
Status: idle
- Process loaded
BPMN Process Execution
Best Practices
- Hook
eventListenerinto a dashboard so you can visualize node enter/exit and token events. - Use
taskExecutorto connect to backends, AI services, or async approval workflows. - Update variables via
setVariableduring execution to influence gateway routing.