Chain steps in one workflow file, each running code, a tool or an agent, so each step's result feeds the next.
Before you start
You need a project. See Create a project.
Build a workflow
- Add the workflow. Each step names a tool and builds its input from the run's
inputor an earlier step's result:workflows/split-bill.tsimport { tool } from "veryfront/tool";import { step, workflow } from "veryfront/workflow"; type Bill = { bill: number; tip: number; people: number }; const addTip = tool({ id: "add-tip", description: "Add a tip, in percent, to a bill.", inputSchema: { type: "object", properties: { bill: { type: "number" }, tip: { type: "number" } }, required: ["bill", "tip"], additionalProperties: false, }, execute: async ({ bill, tip }) => ({ total: Math.round(bill * (1 + tip / 100) * 100) / 100 }),}); const splitEvenly = tool({ id: "split-evenly", description: "Split a total between people.", inputSchema: { type: "object", properties: { total: { type: "number" }, people: { type: "number" } }, required: ["total", "people"], additionalProperties: false, }, execute: async ({ total, people }) => ({ share: Math.round((total / people) * 100) / 100 }),}); export default workflow({ id: "split-bill", description: "Add a tip to a bill and split it between people.", steps: [ step("add-tip", { tool: addTip, input: (ctx) => { const { bill, tip } = ctx.input as Bill; return { bill, tip }; }, }), step("split", { tool: splitEvenly, input: (ctx) => ({ total: (ctx["add-tip"] as { total: number }).total, people: (ctx.input as Bill).people, }), }), ],}); - Run it on your machine.
--inputis the run's input:Shellnpx veryfront workflow run split-bill --input '{"bill": 84.5, "tip": 18, "people": 3}' - Read the result: it prints
"share": 33.24. - Start the project with
npm run dev(Work locally) and open Building blocks > Workflows in Studio. You should now seesplit-billlisted.
Try it in a sandbox
Create a project
Add the workflow
Check it