In the world of workflow automation, complexity is the enemy of reliability. As systems grow, a single failure point can bring an entire process to a halt, leading to hours of frustrating debugging. The solution isn't to build less complex systems, but to build them from simpler, more robust components. This is the core philosophy behind action.do: the fundamental building block of automation.
An action.do represents a single, executable, and indivisible step in a process. Think of it as a Lego brick for your workflows. By chaining these simple, powerful actions together, you can construct sophisticated, automated services and deliver valuable Services-as-Software.
In the context of the .do platform, an atomic action is the smallest possible unit of work. It performs one specific task, and it either succeeds or fails completely. There is no in-between state.
Consider these examples:
By breaking down large processes into these granular, atomic steps, you gain immense benefits:
This principle of executing singular tasks is the foundation for building resilient agentic workflows.
Creating an action is straightforward. Using the .do SDK, you define its metadata and encapsulate its logic. This turns a piece of your business logic into a reusable, executable component.
Let's look at a simple example of an action that sends a welcome email to a new user.
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 what’s happening in this snippet:
A common question is how an action.do differs from a workflow.do. The distinction is simple but crucial:
You build powerful workflows by composing a series of simple actions. A "New User Onboarding" workflow might orchestrate the following actions in sequence:
This composition is how you achieve "business as code"—turning a complex business process into a version-controlled, testable, and automated asset.
Actions are inherently stateless. They receive input, perform their task, and produce output without retaining any memory of previous executions. This design choice is critical for ensuring actions are predictable and reusable across countless different workflows without unexpected side effects. State management, if required, is handled at the higher workflow.do level.
The true power of the .do platform lies in its extensibility. You are not limited to a pre-built library. You can define your own custom actions using the SDK, encapsulating your organization's unique business logic or wrapping any third-party API. Once created, your custom action becomes a first-class citizen, available to be used in any workflow by anyone on your team.
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 performs a single, specific task, like 'send an email' or 'update a database record', ensuring that operations are reliable, testable, and easy to debug.
Q: How does an action.do differ from a workflow.do?
A: 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.
Q: Can I create my own custom actions?
A: 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.
Q: Are actions stateful?
A: 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.