In the world of software development, complexity is the enemy of progress. As we build increasingly sophisticated automations and agentic workflows, the monolithic scripts of yesterday become today's maintenance nightmares. How do we build powerful systems that are also manageable, scalable, and easy to understand? The answer lies in breaking them down to their smallest, most fundamental components: the atomic action.
At action.do, we believe this is the future of building intelligent systems. An atomic action is the foundational building block of automation. By encapsulating every single, repeatable task into a self-contained unit, you can chain them together to create powerful, resilient workflows and deliver true Services-as-Software.
This guide will walk you through what atomic actions are, why they are superior to traditional functions, and how you can start building with them today.
Think of building a complex application like building a house. You don't start by pouring a single, giant slab of concrete. You start with individual bricks. An atomic action is the brick for your automated business processes.
An atomic action is the smallest, indivisible unit of work in a workflow. It's a self-contained, reusable function designed to perform a single task reliably, like 'send an email', 'create a user in a database', or 'query a third-party API'.
This "single responsibility principle" is key. By keeping actions focused, you gain immense benefits:
The best way to understand the power of actions is to see one in practice. Let's define a simple, yet common action: sending a welcome email to a new user.
Using the .do SDK, the code is clean, descriptive, and focused purely on the task's logic.
import { Action } from '@do-sdk/core';
// Define a new Action to send a welcome email
const sendWelcomeEmail = new Action({
name: 'send-welcome-email',
description: 'Sends a standardized welcome email to a new user.',
handler: async (inputs: { email: string; name: string }) => {
console.log(`Preparing to send email to ${inputs.email}...`);
// Logic to connect to an email service (e.g., SendGrid, SES)
// const emailSent = await emailService.send({
// to: inputs.email,
// subject: `Welcome, ${inputs.name}!`,
// body: 'We are so glad you joined us...'
// });
// For this example, we'll simulate a successful API call
const result = { success: true, messageId: `msg_${Date.now()}` };
console.log('Email sent successfully:', result.messageId);
return result;
},
});
// Execute the action via the .do SDK
async function run() {
const execution = await sendWelcomeEmail.run({
email: 'alex@example.com',
name: 'Alex',
});
console.log('Execution Result:', execution);
}
run();
Let's break this down:
"Isn't this just a serverless function?" It's a fair question, but Actions on the .do platform are much more. Think of them as supercharged functions built specifically for workflow orchestration and Business-as-Code.
While a traditional serverless function gives you a blank slate, an Action comes with the framework included. Here’s what you get automatically:
This is the essence of Business-as-Code. Your core business operations are no longer hidden inside monolithic applications; they are explicit, versioned, and reusable code artifacts.
While actions are designed to be atomic, real-world processes are not. So, can an Action call other Actions?
The best practice is to use a workflow.do file to orchestrate multiple actions. This promotes a clear separation of concerns:
For example, a new user onboarding workflow might look like this:
By chaining these simple, self-contained action blocks, you build a complex and robust automation. If the Slack notification fails, it doesn't stop the user from being created or receiving their email. This modular approach is the key to building resilient, scalable systems.
The short answer: virtually any task you can script. If you can code it, you can make it an Action. This unlocks limitless possibilities for API automation and internal tooling.
Common examples include:
By creating a library of these actions, your entire organization can DO MORE, FASTER, composing powerful new automations without reinventing the wheel.
Ready to start building the future of automation? Dive into the .do platform and turn your business logic into powerful, reusable atomic actions.