ai-workflows
Event-driven workflows with the $ context
npm install ai-workflowsHandle events, schedule tasks, and orchestrate processes through the unified $ context.
import { Workflow } from 'ai-workflows'
const workflow = Workflow($ => {
$.on.Customer.created(async (customer, $) => {
$.log('New customer:', customer.name)
await $.send('Email.welcome', { to: customer.email })
})
$.every.Monday.at9am(async ($) => {
$.log('Weekly standup reminder')
})
})
await workflow.start()Event Handling
Events follow the Noun.verb pattern:
$.on.Order.placed(handler)
$.on.Payment.completed(handler)
$.on.Customer.upgraded(handler)Scheduling
Natural language scheduling:
$.every.hour(handler)
$.every.Monday.at9am(handler)
$.every.minutes(30)(handler)
$.every('first Monday of the month', handler)Exports
| Export | Description |
|---|---|
Workflow | Create workflow with $ context |
on | Standalone event registration |
every | Standalone scheduling |
send | Emit events |
createTestContext | Testing utilities |
Related
- Workflow Primitive — Full documentation
- ai-functions — Functions to orchestrate
- human-in-the-loop — Human steps
Was this page helpful?