Automation isn't just about what you do; it's about when you do it. A timely action can be the difference between a closed deal and a missed opportunity, a smooth operation and a critical failure. In the world of agentic workflows, the trigger is just as important as the task itself. This is where schedule.when comes in—the intelligent, flexible scheduling engine for the .do platform.
At its core, the .do platform is built on the concept of atomic actions: small, reusable, and observable units of work that form the foundation of your business logic. But how do you run these workflows without manual intervention? schedule.when gives you the power to trigger any workflow at any time, using two powerful methods: the precision of cron and the simplicity of natural language.
Scheduled tasks are the silent workhorses of modern business. They handle the routine, the repetitive, and the critical, ensuring your operations run like clockwork. With schedule.when, you can automate essential processes such as:
schedule.when bridges the gap between defining your business logic as code and executing it at the exact moment it's needed.
For developers and system administrators who demand absolute precision, schedule.when offers full support for standard cron expressions. This battle-tested syntax gives you granular control over your schedule, allowing you to define complex recurring tasks with a single, powerful string.
Let's say you have a workflow.do agent that compiles and emails a sales report. You can schedule it to run at 8:00 AM UTC every weekday with just a few lines of code.
import { Do } from '@do-platform/sdk';
// Initialize the .do client
const-do = new Do(process.env.DO_API_KEY);
// Get the workflow you want to schedule
const reportWorkflow = await-do.workflow.get('generate-daily-sales-report');
// Schedule it with a cron expression
await reportWorkflow.schedule({
when: '0 8 * * 1-5', // 8:00 AM UTC, Monday to Friday
inputs: {
recipient: 'sales-team@yourcompany.com'
}
});
console.log('Daily sales report workflow scheduled!');
Using cron gives you the power and reliability that professionals expect, fully integrated into the observable and managed .do environment.
This is where schedule.when truly shines. While cron is powerful, it can be cryptic. The .do platform embraces the "agentic" future by allowing you to define schedules using simple, human-readable language. Our engine intelligently parses your intent, making scheduling more accessible and your code more readable.
Want to run a database cleanup job at the end of each week? Forget trying to remember the right cron syntax.
import { Do } from '@do-platform/sdk';
const-do = new Do(process.env.DO_API_KEY);
const cleanupWorkflow = await-do.workflow.get('archive-old-records');
// Schedule it using a simple phrase
await cleanupWorkflow.schedule({
when: 'every friday at 11pm',
inputs: {
retentionDays: 90
}
});
console.log('Cleanup workflow scheduled with natural language!');
The schedule.when parser understands a wide variety of phrases, giving your team an intuitive way to automate:
This natural language capability lowers the barrier to entry for creating powerful automations and makes your codebase self-documenting.
Remember, a schedule doesn't just trigger a single function; it kicks off a workflow. A .workflow.do agent is designed to orchestrate a sequence of atomic action.do units.
This architecture is key to building robust systems.
By using schedule.when as the entry point, your entire business process runs automatically, but each workflow step remains an isolated, testable, and reusable atomic action. This separation of concerns—scheduling, orchestration, and execution—is the hallmark of a resilient and scalable automation strategy.
Running a cron job on a server is fragile. What if the server goes down? How do you monitor its execution? schedule.when is a fully managed, first-class citizen of the .do platform, providing benefits far beyond a simple task scheduler:
Stop managing your own scheduling infrastructure and start defining your business cadence as code. With the dual power of cron and natural language, schedule.when offers the flexibility and reliability you need to put your agentic workflows on autopilot.