Skip to main content

Finish Workflow

Now let's update the workflow to complete the flow.

Update Workflow

In approval-process.ts, update the workflow to call the wait-for-approval task and then emit the jobApproved event.

import { workflow } from "@eventual/core";
import { jobApproved } from "./job-approved.js";
import { waitForApproval } from "./wait-for-approval.js";

export const approvalProcess = workflow(
async (description: string, context) => {
const result = await waitForApproval({
description: description,

await jobApproved.emit({ jobId:, approved: result });

if (result) {
return "Job was approved";
return "Job was not approved.";

The workflow will invoke the task and wait indefinitely until the task is completed.


For information on configuring timeouts and heartbeats, see the documentation for tasks and workflows.