Flow Studio
Built-In Workflow Events
Five events are published automatically by the ProcessEngine at key workflow lifecycle transitions. Subscribe to any combination to build webhook delivery, audit logs, dashboards, and billing integrations.
Event Reference
| Event Class | When Published | Key Payload Fields |
|---|---|---|
WorkflowStarted | Execution begins (first node queued) | ExecutionId, ProcessId, TenantId, TriggeredBy, StartedAt |
WorkflowCompleted | All nodes finished successfully | ExecutionId, ProcessId, TenantId, DurationMs, CompletedAt |
WorkflowFailed | A node threw an unrecoverable error | ExecutionId, ProcessId, TenantId, FailedNodeId, Error, FailedAt |
WorkflowPaused | A HIL node suspended the execution | ExecutionId, ProcessId, TenantId, SuspendedNodeId, SuspendedAt |
WorkflowResumed | A HIL resume call restarted execution | ExecutionId, ProcessId, TenantId, ResumedAt, ResumedBy |
WorkflowStarted
public class WorkflowStarted : WorkflowEvent
{
public string TriggeredBy { get; init; } // userId or "system"
public DateTimeOffset StartedAt { get; init; }
public Dictionary<string, object>? TriggerPayload { get; init; }
}
WorkflowCompleted
public class WorkflowCompleted : WorkflowEvent
{
public long DurationMs { get; init; }
public DateTimeOffset CompletedAt { get; init; }
public WorkflowStatus Status { get; init; } // Success
}
WorkflowFailed
public class WorkflowFailed : WorkflowEvent
{
public string FailedNodeId { get; init; }
public string FailedNodeType { get; init; }
public string ErrorMessage { get; init; }
public string? ErrorType { get; init; }
public DateTimeOffset FailedAt { get; init; }
}
WorkflowPaused
public class WorkflowPaused : WorkflowEvent
{
public string SuspendedNodeId { get; init; }
public string CorrelationToken { get; init; }
public string ActorId { get; init; }
public DateTimeOffset SuspendedAt { get; init; }
public DateTimeOffset? ExpiresAt { get; init; }
}
WorkflowResumed
public class WorkflowResumed : WorkflowEvent
{
public string ResumedBy { get; init; } // userId who responded
public string CorrelationToken { get; init; }
public DateTimeOffset ResumedAt { get; init; }
}
Subscribing to a Built-In Event (Example)
// Handler: send a webhook when a workflow completes or fails
public class WorkflowWebhookHandler :
IWorkflowEventHandler<WorkflowCompleted>,
IWorkflowEventHandler<WorkflowFailed>
{
private readonly IWebhookService _webhooks;
public WorkflowWebhookHandler(IWebhookService webhooks) => _webhooks = webhooks;
public async Task HandleAsync(WorkflowCompleted @event, CancellationToken ct)
{
await _webhooks.DeliverAsync(@event.ProcessId, "completed", new
{
executionId = @event.ExecutionId,
durationMs = @event.DurationMs,
status = "success"
}, ct);
}
public async Task HandleAsync(WorkflowFailed @event, CancellationToken ct)
{
await _webhooks.DeliverAsync(@event.ProcessId, "failed", new
{
executionId = @event.ExecutionId,
failedNode = @event.FailedNodeId,
errorMessage = @event.ErrorMessage
}, ct);
}
}
// Registration (both event types, same handler class)
services.AddTransient<IWorkflowEventHandler<WorkflowCompleted>, WorkflowWebhookHandler>();
services.AddTransient<IWorkflowEventHandler<WorkflowFailed>, WorkflowWebhookHandler>();