Pause a workflow at a waitForApproval step: its run waits until a person approves, then carries on.
Before you start
You need a workflow. See Build a workflow.
Add an approval
-
In your project, open Building blocks > Workflows.
-
Click Create workflow.
-
Enter
approve-refundas the Name. -
Replace the Source code with a workflow that waits for approval before it issues a refund:
TypeScriptimport { tool } from "veryfront/tool";import { step, waitForApproval, workflow } from "veryfront/workflow"; const issueRefund = tool({ id: "issue-refund", description: "Issue a refund for an amount.", inputSchema: { type: "object", properties: { amount: { type: "number" } }, required: ["amount"], additionalProperties: false, }, execute: async ({ amount }) => ({ refunded: amount, status: "issued" }),}); export default workflow({ id: "approve-refund", description: "Issue a refund once a person approves it.", steps: [ waitForApproval("manager-approval", { message: "Approve this refund?", timeout: "24h", }), step("issue-refund", { tool: issueRefund, input: (ctx) => ({ amount: (ctx.input as { amount: number }).amount }), }), ],}); -
Click Create workflow.
-
Open the ⋯ menu.
-
Click Run workflow.
-
Paste the Payload:
JSON{ "amount": 25 } -
Click Create run. The run shows Waiting, with
manager-approvalunder Pending approvals. -
Ask a teammate who can run workflows to open Orchestration > Runs.
-
They click the run.
-
They click Approve.
-
Open the run again. You should now see it Completed, with
"refunded": 25under Output.
Troubleshooting
If Studio says "You started this run, so someone else has to approve it", the person who starts a run can't approve it. Ask a teammate to approve it.