In the world of workflow automation, complexity is the enemy. As we build more sophisticated systems to handle business processes, the risk of creating tangled, brittle, and unmanageable tangles of code grows. How do we build powerful, agentic workflows without sacrificing reliability and maintainability?
The answer lies in starting with the smallest possible unit: the atomic action. On the .do platform, action.do represents this fundamental building block. It's a single, executable step designed to perform one task, and one task only. By embracing this "Business as Code" philosophy, you can compose intricate automations from simple, powerful, and reusable components.
Think of an automated workflow as a detailed recipe. The entire recipe might be "Onboard a New Customer." This is a complex process with many moving parts. An atomic action is a single instruction within that recipe, like "send a welcome email" or "update a database record."
In the context of .do, an atomic action is the smallest, indivisible unit of work. It’s designed to be:
These actions are the stable foundation upon which robust, automated services are built.
Creating an action is straightforward. Using the @do-sdk/core, you define its identity, describe its purpose, and encapsulate its logic within an execute function.
Let's look at the building block for sending a welcome email:
import { action } from '@do-sdk/core';
// Define an action to send a welcome email
const sendWelcomeEmail = action.create({
id: 'send-welcome-email',
description: 'Sends a welcome email to a new user.',
execute: async ({ email, name }) => {
// Your email sending logic via an external API
console.log(`Sending welcome email to ${name} at ${email}...`);
return { success: true, messageId: 'xyz-123' };
}
});
// Execute the action
const result = await sendWelcomeEmail.execute({
email: 'jane.doe@example.com',
name: 'Jane Doe'
});
Here’s a breakdown of this code:
This self-contained unit can now be executed, tested, and—most importantly—reused across countless workflows.
Breaking down processes into atomic actions isn't just an organizational exercise; it provides tangible benefits that are crucial for building enterprise-grade automations.
Rock-Solid Reliability: Because actions are stateless, they are predictable. Given the same input, an action will always attempt the same operation and produce a consistent output format. This eliminates side effects that plague monolithic scripts.
Effortless Debugging: When a complex workflow fails, how do you find the root cause? With atomic actions, the system can pinpoint the exact step that failed—for example, send-welcome-email returned an error. You debug a small, isolated unit of logic, not a 500-line script.
Maximum Reusability: The send-welcome-email action is not tied to a single user onboarding process. You can reuse it in a password reset workflow, a subscription confirmation service, or any other process that needs to send an email. Define once, use everywhere.
Simplified Testing: Unit testing a single-purpose function is trivial. You can test your action.do in complete isolation to verify its logic without needing to run an entire end-to-end workflow, dramatically speeding up development cycles.
It's crucial to understand the relationship between an action.do and a workflow.do.
You build powerful workflow.do services by composing a series of simple actions. For example, a user-onboarding.workflow.do might chain together several actions:
This composition is how you deliver valuable Services-as-Software. You start with simple, atomic building blocks and assemble them into sophisticated, automated processes that drive real business value. By embracing the power of action.do, you're not just writing scripts; you're engineering the future of your business operations.
An atomic action is the smallest, indivisible unit of work in a workflow. It performs a single, specific task, like 'send an email' or 'update a database record', ensuring that operations are reliable, testable, and easy to debug.
An action.do represents a single step, while a workflow.do orchestrates multiple actions to achieve a larger business outcome. You build powerful workflows by composing a series of simple actions.
Yes. The .do platform is designed for extensibility. You can define your own custom actions using our SDK, encapsulating your specific business logic and integrating any third-party API to make them available in any workflow.
No, actions are stateless by design. They receive input, perform their task, and produce output without retaining memory of previous executions. State management is handled at the workflow level, ensuring actions are reusable and predictable.