In the world of business automation, reliability and clarity are paramount. We previously introduced action.do as the fundamental building block of this new paradigm—an atomic, reusable unit of work that performs a single task flawlessly. An action can enrich a user profile, send an invoice, or update a database record. They are the verbs of your business processes.
But what happens when you need to string those verbs together into a coherent sentence, or even a full story? How do you handle a multi-step process like new user onboarding, which involves enrichment, sending a welcome email, and maybe even assigning a task to a sales representative?
This is where orchestration comes in. This is the role of workflow.do.
If an action.do is a single, perfectly crafted Lego brick, a workflow.do is the instruction manual that shows you how to build a complete, functional model. It defines the sequence, logic, and flow that connects your individual actions into a powerful, automated business process.
A workflow.do is a managed agent on the .do platform responsible for orchestrating multiple action.do units. It's where you define the "big picture"—the business logic that dictates which actions run, in what order, and under what conditions.
This separation is a core principle of the .do platform. A critical design choice we made is that actions cannot call other actions. All orchestration must happen within a workflow.
Why? This separation of concerns is the key to building robust, scalable, and maintainable systems:
Let's make this concrete. Imagine we have the enrich-user-profile action from our previous post. It takes an email, looks up data, and updates our database.
// Previously defined action.do
const enrichUserAction = await do.action.create({
name: 'enrich-user-profile',
// ... handler logic to call Clearbit and update DB
});
Now, let's build a new-user-onboarding workflow that uses this action as its first step.
import { Do } from '@do-platform/sdk';
// Initialize the .do client
const do = new Do(process.env.DO_API_KEY);
// Define a new workflow to onboard users
const onboardUserWorkflow = await do.workflow.create({
name: 'new-user-onboarding',
description: 'Handles the full onboarding process for a new user sign-up.',
// A workflow can be triggered by an event, a schedule, or a direct API call
trigger: {
event: 'user.created'
},
handler: async (trigger) => {
console.log(`Starting onboarding for: ${trigger.payload.email}`);
try {
// Step 1: Run our existing action to enrich the user profile
const enrichedData = await do.action.run('enrich-user-profile', {
email: trigger.payload.email
});
// Step 2: Use conditional logic based on the action's output
if (enrichedData.success) {
// Run another action to send a welcome email
await do.action.run('send-welcome-email', {
userId: enrichedData.userId,
template: 'welcome-standard'
});
}
// Step 3: Run a different action to create a task in our CRM
await do.action.run('create-crm-task', {
userId: enrichedData.userId,
task: 'Follow up with new user in 7 days.'
});
} catch (error) {
// Step 4 (Error Handling): If any action fails, create an alert
console.error('Onboarding workflow failed.', error);
await do.action.run('create-support-alert', {
email: trigger.payload.email,
reason: 'Onboarding workflow failed during execution.'
});
}
return { status: 'completed' };
}
});
console.log('Workflow created:', onboardUserWorkflow.id);
In this example, the workflow.do handler doesn't contain the complex implementation details. It simply reads like a business plan:
The workflow manages state, passes outputs from one action as inputs to the next, and handles errors gracefully. This is Business-as-Code in its purest form.
A workflow.do is more than just a script. It's a stateful, observable, and durable agent. It can run for minutes, hours, or even days, pausing for human input or waiting for external events. Because it's a fully managed entity on the .do platform, you get:
By combining the atomic power of action.do with the intelligent orchestration of workflow.do, you move beyond simple automation. You begin building an agentic system—a digital workforce that can execute complex, multi-step business processes with unparalleled reliability and clarity.
Ready to compose your masterpiece? Start orchestrating your business logic with .do and transform your processes from fragile scripts into robust, scalable workflows.