In the world of automated and agentic workflows, complexity is the enemy of reliability. As we stitch together APIs, databases, and third-party services to create sophisticated data pipelines, we introduce countless points of failure. A network glitch, a temporary service outage, a malformed payload—any of these can leave our systems in a dreaded "in-between" state, corrupting data and causing downstream chaos.
How do we build robust systems that can withstand this chaos? The answer lies in a principle borrowed from database theory: atomicity. By breaking down complex processes into their smallest, indivisible parts, we can ensure our automations are reliable, predictable, and maintain data integrity every step of the way.
Welcome to action.do, the building block of modern automation.
Before diving into the "how," let's solidify the "what." In the context of action.do, an atomic action is the smallest, indivisible unit of work in a workflow.
Think of it as a transaction with a simple promise: it will either complete successfully or fail entirely, leaving no partial or inconsistent state behind. There is no middle ground.
Consider a user signup process that involves two steps:
If the database entry succeeds but the email service fails, you're left with a "ghost" user who never received their onboarding information. With an atomic action encapsulating this entire process, a failure in the email step could trigger a rollback of the database entry, ensuring your system remains in a clean, consistent state. This is the power of atomicity.
action.do is built on this core principle. We provide a simple yet powerful framework for you to define, execute, and manage atomic actions as API-callable endpoints. By encapsulating single, repeatable tasks, you can transform tangled, brittle scripts into a library of robust, scalable building blocks for your agentic workflows.
Our philosophy is simple: Simple. Atomic. Powerful.
Defining an action is straightforward. You don't need complex configurations or boilerplate. With our SDK, you can declare an action directly in your codebase, turning business logic into a managed, executable task.
Here’s how you would define an action to send a welcome email using TypeScript:
import { action } from '@do-sdk/core';
export const sendWelcomeEmail = action({
// A unique, human-readable identifier
name: 'send-welcome-email',
// Clear description for discoverability
description: 'Sends a welcome email to a new user.',
// Strongly-typed inputs with validation
inputs: {
to: { type: 'string', required: true },
name: { type: 'string', required: true }
},
// The core logic of the action
handler: async ({ inputs, context }) => {
const { to, name } = inputs;
// Your business logic goes here: API calls, DB queries, etc.
console.log(`Sending welcome email to ${name} at ${to}`);
// Return a structured output
return { success: true, messageId: 'xyz-123' };
},
});
Let's break this down:
An atomic action is powerful on its own, but its true potential is unlocked when composed into larger processes. This is where the distinction between an action.do and a workflow.do becomes important.
Because actions are designed to be modular, you can define an action like generate-monthly-report once and reuse it across multiple workflows, from finance to sales. This promotes the DRY (Don't Repeat Yourself) principle, making your automations easier to maintain and scale.
Stop letting partial failures and inconsistent states compromise your data. By embracing the principles of business-as-code and atomicity, you can build agentic workflows that are not just powerful, but also fundamentally reliable.
With action.do, you can turn complex processes into simple, repeatable tasks that form the foundation of secure and scalable automation.
Ready to build your first atomic action? Get started with the action.do API today!
Q: What is an 'atomic action' in the context of .do?
A: 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.
Q: How is an action.do different from a full workflow.do?
A: 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.
Q: Can I reuse actions across different workflows?
A: 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.
Q: What kind of logic can I put inside an action's handler?
A: 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.