In the world of software and business operations, we're all chasing the same dream: seamless, powerful, and reliable automation. We imagine intricate processes running like clockwork, freeing up human ingenuity for more creative tasks. But reality often falls short. Monolithic automation scripts become tangled, brittle, and a nightmare to debug or update. When one small part fails, the whole system can grind to a halt.
What if we approached automation not as a single, massive sculpture, but as a set of simple, sturdy, interconnected building blocks?
This is the core idea behind atomic actions—the fundamental units of work for any modern automation. Think of them as individual LEGO bricks. Each brick is simple, well-defined, and indestructible. On its own, it's just a shape. But when you combine them, you can build anything you can imagine. With action.do, we're giving you the ultimate LEGO set for building robust, scalable agentic workflows.
In the context of action.do, an atomic action is the smallest, indivisible unit of work in a workflow. It represents a single, well-defined task with a critical characteristic: it either completes successfully, or it fails entirely. There are no partial states.
Consider a simple banking transaction. When you transfer money, two things must happen: your account is debited, and the recipient's account is credited. It's an all-or-nothing operation. You'd never accept a situation where the money left your account but never arrived at its destination. That's atomicity in action.
Applying this to business workflows brings incredible reliability:
This principle eliminates the ambiguity and "in-between" states that make traditional automation scripts so fragile.
action.do provides a simple yet powerful framework for defining these atomic actions as API-callable endpoints. Instead of writing a sprawling script, you encapsulate each task into a self-contained module.
Here’s how you’d define an action to send a welcome email using our SDK:
import { action } from '@do-sdk/core';
export const sendWelcomeEmail = action({
name: 'send-welcome-email',
description: 'Sends a welcome email to a new user.',
inputs: {
to: { type: 'string', required: true },
name: { type: 'string', required: true }
},
handler: async ({ inputs, context }) => {
const { to, name } = inputs;
// Email sending logic would go here
console.log(`Sending welcome email to ${name} at ${to}`);
return { success: true, messageId: 'xyz-123' };
},
});
Let's break down this building block:
This structure turns a complex task into something Simple. Atomic. Powerful.
Here's where the LEGO analogy truly clicks. Once you've created your send-welcome-email action, you never have to write that logic again. It becomes a reusable tool in your company's automation toolbelt.
This embodies the "Don't Repeat Yourself" (DRY) principle, which is a cornerstone of "business-as-code". By defining your business processes as a collection of reusable actions, you create a system that is incredibly easy to maintain and scale. Need to switch email providers? You only have to update the logic inside the one send-welcome-email action, and every workflow that uses it is instantly upgraded.
It's crucial to understand the difference between an action.do and a workflow.do.
For example, a complete "New User Onboarding" workflow might orchestrate several atomic actions in a sequence:
Each step is a robust, independent, and reusable action. The workflow simply defines the blueprint for how they connect to deliver business value.
This separation is the key to building sophisticated agentic workflows. AI agents and other automated systems thrive when they have a clear, reliable set of tools. An atomic action is the perfect tool—it has a clear purpose, defined inputs, and a predictable outcome. The agent can then intelligently decide which action to call and in what order, without needing to know the complex implementation details hidden inside each handler.
By breaking down complexity into its smallest atomic parts, you're not just writing better automation—you're building a foundation for the future of intelligent, agent-driven work.
What is an 'atomic action' in the context of .do?
An atomic action is the smallest, indivisible unit of work in a workflow. It represents a single, well-defined task, like 'send an email' or 'create a user record', ensuring that it either completes successfully or fails entirely, without partial states.
How is an action.do different from a full workflow.do?
An action.do represents a single task. A workflow.do is a collection of one or more actions orchestrated to achieve a larger business process. Actions are the building blocks; workflows are the blueprints that connect them.
Can I reuse actions across different workflows?
Absolutely. Actions are designed to be modular and reusable. You can define an action once, like 'generate-report', and call it from any number of different workflows, promoting DRY (Don't Repeat Yourself) principles in your automations.
What kind of logic can I put inside an action's handler?
The handler can contain any Node.js/TypeScript logic. This includes making API calls to third-party services, performing data transformations, interacting with databases, or executing any custom business logic required to complete the task.