Skip to Content
Workflows

Workflows

Workflows are triggered by events or timers. Use on() for event-driven tasks and every() for schedules.

import { every, on } from 'workflows.do' // run hourly to enrich new ideas in the database every('hour during business hours', async (_, { ai, db }) => { const drafts = await db.ideas.search('status:draft') for (const idea of drafts) { const leanCanvas = await ai.defineLeanCanvas({ idea }) const research = await ai.research({ idea, leanCanvas }) await db.ideas.update({ ...idea, leanCanvas, research }) } }) // react to external events from other systems on('CreditApp.Submitted', async ({ creditApp }, { ai, db }) => { const score = await ai.call('riskScore', { creditReport: creditApp.creditReport, income: creditApp.income }) const terms = await ai.call('priceLoan', { score, amount: creditApp.amount, term: creditApp.term }) await db.creditApps.update({ ...creditApp, score, terms }) })

Workflows coordinate calls to your functions and database so tasks can run automatically.

Last updated on