In the world of workflow automation, complexity is a constant challenge. As business processes grow, the automations that power them can become monolithic, brittle, and nearly impossible to debug. When a single step in a 20-step process fails, how do you quickly identify and fix the issue without bringing the entire system down? The answer lies in breaking things down to their most fundamental level: the atomic action.
At its core, an atomic action is the smallest, indivisible unit of work. It’s a single, executable step that does one thing and does it well. This is the philosophy behind action.do—the foundational building block of automation on the .do platform. By creating and chaining these simple, powerful actions, you can build complex, reliable services and deliver true Services-as-Software.
This post will guide you beyond using pre-built functions and show you how to create your own custom action.do tasks for maximum flexibility and control in your agentic workflows.
An action.do represents a single, indivisible task. Think of it not as the entire assembly line, but as one specialized robotic arm on that line. It might perform a task like "send an email," "update a database record," or "call a specific API endpoint."
This "atomic" approach provides several key advantages:
An action.do is the step; a workflow.do is the journey. You build powerful workflows by orchestrating a sequence of simple, modular action.do components.
While the .do platform offers a library of common actions, the real power comes from encapsulating your unique business logic. Let's say you want to create an action that sends a welcome email to a new user. Using the .do SDK, the code is remarkably clean and intuitive.
Here’s how you would define and execute a custom action.do to send 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
// e.g., using SendGrid, Postmark, or AWS SES
console.log(`Sending welcome email to ${name} at ${email}...`);
// The action should return a structured result
return { success: true, messageId: 'xyz-123' };
}
});
// Execute the action to test or use it
const result = await sendWelcomeEmail.execute({
email: 'jane.doe@example.com',
name: 'Jane Doe'
});
console.log(result);
// Expected output: { success: true, messageId: 'xyz-123' }
Let's break this down:
By defining your business processes as a collection of such actions, you are engaging in business as code—creating a version-controlled, testable, and transparent representation of how your company operates.
To unlock the full potential of action.do, keep these design principles in mind:
By following these guidelines, you'll build a library of robust, interchangeable components that can be assembled to automate virtually any business process. You are no longer just writing scripts; you are engineering valuable Services-as-Software.
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.