In today's digital-first landscape, businesses run on processes. From processing a customer payment to sending a welcome email or updating a CRM, these operations are the lifeblood of your company. Yet, too often, this critical business logic is fragmented across different services, buried within monolithic applications, or worse, reliant on manual, error-prone tasks.
What if you could treat your core business operations like version-controlled, reusable, and composable software assets? This is the central promise of Business-as-Code, a paradigm that transforms abstract processes into tangible digital building blocks. With the .do platform, this is not just a concept—it's a reality powered by atomic actions.
At the heart of the Business-as-Code movement is the atomic action. An atomic action is a self-contained, single-purpose function that performs one specific task reliably and predictably. Think of it as the ultimate microservice: a focused, independent unit of work that does one thing and does it exceptionally well.
On the .do platform, an atomic action lets you:
This transforms your logic from a simple script into a robust, scalable, and observable digital asset—the fundamental building block for creating sophisticated, AI-powered agentic workflows.
Defining an action on the .do platform is designed to be intuitive and powerful. You declare what your action does, what it needs, and how it runs, all in a clean, declarative format.
Let's look at a simple process-payment action:
import { Do } from '@do-sdk/core';
// Define an atomic action to process a payment
const processPayment = Do.action('process-payment', {
inputs: {
customerId: 'string',
amount: 'number',
},
handler: async ({ inputs, context }) => {
// Connect to a payment provider like Stripe
console.log(`Processing payment of $${inputs.amount} for ${inputs.customerId}`);
// ... payment gateway logic here
// Return a structured result
return { success: true, transactionId: `txn_${context.runId}` };
},
});
// Execute the action securely via the .do API
const result = await processPayment.run({
customerId: 'cust_12345',
amount: 49.99,
});
console.log(result);
// Output: { success: true, transactionId: 'txn_...' }
Let's break this down:
You might be thinking, "Isn't this just a serverless function?" While similar in concept, an action.do is purpose-built for creating resilient and intelligent business automation.
A standard serverless function gives you a place to run code. An action.do treats your business logic as a first-class citizen within a broader ecosystem. It comes with native integration for:
This focus elevates your code from a simple function to a managed, reusable, and secure business asset.
The true power of atomicity emerges when you start composing actions. By ensuring each action has a single responsibility, you can build incredibly complex and robust workflows that are easy to maintain and debug.
Consider a new user onboarding workflow:
Each step is an independent, reusable atomic action. If you decide to switch email providers, you only need to update the send-welcome-email action. The rest of the workflow remains untouched. This modularity is a cornerstone of maintainable and scalable agentic workflows.
Q: What is an 'atomic action' on the .do platform?
A: An atomic action is a self-contained, single-purpose function that performs one specific task, like sending an email or updating a database record. It's the fundamental building block for creating reliable and modular agentic workflows.
Q: How is an action.do different from a standard serverless function?
A: While similar, an action.do is purpose-built for agentic systems. It includes native integration with the .do ecosystem for state management, observability, and composition, allowing you to treat business logic as a first-class citizen in your Services-as-Software.
Q: Can actions call other actions?
A: A single action is designed to be atomic and perform one task. To orchestrate multiple actions, you use a 'workflow.do', which composes individual actions into a larger, stateful process. This promotes a clean separation of concerns.
Q: What kind of logic can I run inside an action.do?
A: Anything you can code. Actions can perform data transformations, integrate with third-party APIs (e.g., Stripe, SendGrid), query databases, or run machine learning models. It encapsulates any unit of business logic and exposes it as a simple API.
Q: How are inputs and secrets handled in an action?
A: Inputs are defined with clear types in the action's configuration and are passed during execution. Secrets, like API keys or database credentials, are managed securely through the .do platform and injected into the action's context at runtime, never exposed in your code.