Home / Use Cases / AI-generated BPMN workflows

AI-generated BPMN workflows

Why this matters for your team: a process owner can describe a workflow in plain language and get back a valid, deployable BPMN diagram — one your analysts can still review and edit visually — instead of waiting on a developer to hand-draw it.

Asking an LLM to write raw BPMN 2.0 XML is a bad time — a hallucinated element ID or a mismatched sequence flow reference is easy to produce and hard for the model to catch. @bpmnkit/core's fluent builder gives the model a much smaller, type-checked surface to work with instead: a chain of method calls that can only construct valid BPMN.

How it works

An LLM (or a deterministic planning step) produces a compact intermediate description of the process — which tasks, which gateways, which branches — small enough to fit in a single prompt. That description is compiled into a real ProcessBuilder chain:

import { Bpmn } from "@bpmnkit/core";

const xml = Bpmn.export(
  Bpmn.createProcess("support-ticket")
    .startEvent("start", { name: "Ticket Created" })
    .exclusiveGateway("gw", { name: "Severity?" })
    .branch("high", (b) =>
      b.condition("= severity = \"high\"")
        .serviceTask("escalate", { taskType: "escalate-to-oncall" })
        .endEvent("end-escalated"),
    )
    .branch("normal", (b) =>
      b.defaultFlow()
        .userTask("triage", { name: "Triage Ticket" })
        .endEvent("end-triaged"),
    )
    .withAutoLayout()
    .build()
);

Because every call is type-checked, a model that tries to reference a task that doesn't exist, or attach a gateway with no branches, fails at generation time rather than producing silently-broken XML.

Where this fits

This is the same approach used for AI-assisted design inside BPMN Kit's own editor and CLI (casen) — see the AI guide in the docs for the full pipeline, including the plan format and deploy-readiness linting that runs before a generated process reaches Camunda 8.

Frequently asked

Why not have the LLM write BPMN XML directly?

BPMN 2.0 XML is verbose and easy to get subtly wrong — mismatched IDs, missing sequence flow references, invalid Zeebe extension elements. A fluent builder API constrains the LLM to valid operations at every step, and TypeScript's type checker catches structural mistakes before the diagram is ever exported.

Does the LLM need to compute the diagram layout?

No — @bpmnkit/core's .withAutoLayout() runs a Sugiyama layout pass after the process is built, so the model only needs to describe the process structure, not x/y coordinates.