> For the complete documentation index, see [llms.txt](https://bus.node-ts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bus.node-ts.com/guide/workflows/completing.md).

# Completing

A workflow is completed by returning `this.completeWorkflow()` from within a handler. This will set the state of the workflow to `completed` and will no longer be activated by any incoming messages.

```typescript
import { Workflow } from '@node-ts/bus-core'

export class FulfilmentWorkflow extends Workflow<FulfilmentWorkflowState> {
  configureWorkflow (
    mapper: WorkflowMapper<FulfilmentWorkflowState, FulfilmentWorkflow>
  ): void {
    mapper
      .withState(FulfilmentWorkflowState)
      // ...
      .when(ReceiptSent, 'complete')
  }
  
  async complete (_: ReceiptSent) {
    return this.completeWorkflow()
  }
}
```

Final changes to the workflow state can be passed in as a parameter to `completeWorkflow()` if desired

```typescript

export class FulfilmentWorkflow extends Workflow<FulfilmentWorkflowState> {
  configureWorkflow (
    mapper: WorkflowMapper<FulfilmentWorkflowState, FulfilmentWorkflow>
  ): void {
    mapper
      .withState(FulfilmentWorkflowState)
      // ...
      .when(ReceiptSent, 'complete')
  }
  
  async complete (_: ReceiptSent) {
    return this.completeWorkflow({ status: 'complete' })
  }
}
```
