Skip to content

@WorkflowFinish

The @WorkflowFinish decorator defines a terminal node (workflows/<workflow-name>/<finish-name>.workflow-finish.ts) where a @Workflow path completes and returns a typed output DTO to the caller of app.execute() (or to a parent workflow calling .toWorkflow(Child)). A finish can be a pass-through (returning the latest output DTO already in Path Scope) or a handled finish implementing FinishHandler<Self> to assemble its output from multiple scoped DTOs and injected services.

Complete @WorkflowFinish examples (pass-through and FinishHandler)

Section titled “Complete @WorkflowFinish examples (pass-through and FinishHandler)”

Every @WorkflowFinish class name ends with WorkflowFinish and its name option ends with -workflow-finish:

Option Type Required Description
name string Yes Unique kebab-case identifier ending with -workflow-finish (e.g., "offer-sent-workflow-finish").
description string Yes Description of this terminal outcome; also used by agboss describe and studio visualizations.
output DtoClass Yes The DTO class returned in result.output when execution ends at this finish node.
input InputFields No Map of DTOs read from Path Scope. When omitted, the finish is a pass-through; when set, the class must implement FinishHandler<Self>.
deps readonly Token[] No Constructor dependencies (ExecutionContext, Clock, @Injectable services) injected into a handled finish.
Section titled “What related entities work with @WorkflowFinish?”
Related Entity Import Path Purpose
FinishHandler<Self> "@agboss/core" Interface implemented by @WorkflowFinish classes that declare input (finish(input): OutputOf<Self> | Promise<OutputOf<Self>>).
WorkflowFinishTextDto "@agboss/core/dto" Standard built-in output DTO ({ text: string }) for text-returning workflows.
.toFinish(FinishClass) Flow chain Terminates a path in @Workflow({ flow }) after the compiler verifies FinishClass’s required DTOs exist on the path.
result.finish & result.output "@agboss/core" On ExecutionStatus.Finished, result.finish.name identifies which @WorkflowFinish ended the run and result.output holds the validated DTO.