JustFlows

Elsa Workflows / Integrations

Start workflows from a plugin

Another plugin starts Elsa workflows through the plugin's SDK, for the current site, without ever handling the Elsa credentials:

typescript
const elsa = globalThis[Symbol.for("justflows.elsa-workflows.sdk")];

const result = await elsa?.triggerElsaEvent({
  eventName: "acme.booking.confirmed",
  correlationId: bookingId,
  source: "acme.bookings",
  input: { bookingId },
});
// { ok: true, instanceIds, correlationId } or { ok: false, error }
FunctionWhat it does
triggerElsaEventPublishes an Elsa event. Every workflow that starts with an Event activity of that name runs.
dispatchElsaWorkflowQueues one published definition by id.
executeElsaWorkflowRuns one published definition and waits for Elsa to accept the instance.

After a successful call the plugin emits justflows.elsa-workflows.eventTriggered, .workflowDispatched, or .workflowStarted. They are also webhook event types. The developer guides cover the inputs, results, and errors.