AI agents are poised to revolutionize how we automate work. They can understand natural language, reason about problems, and make decisions. But there's a critical gap between an agent deciding what to do and reliably doing it. When an AI needs to interact with the real world—process a payment, update a CRM, or send a critical notification—ambiguity is the enemy. Hallucinations or failed API calls can break entire processes.
To build truly robust agentic workflows, our AI needs more than just intelligence; it needs a toolbox of reliable, predictable, and indestructible tools.
This is the core principle behind action.do: transforming any piece of business logic into a reliable, scalable, and observable atomic action. It's the fundamental building block for moving from promising AI prototypes to production-grade business automation.
Encapsulate Logic. Execute Flawlessly.
On the .do platform, an atomic action is a self-contained, single-purpose function that performs one specific task perfectly.
Think of it this way: instead of giving your agent a complex, clunky multi-tool, you give it a set of perfectly sharpened, single-purpose instruments.
Each action has a clearly defined job. It takes specific inputs and produces a structured output. It either succeeds or fails, with no in-between. This atomicity is the key to reliability. By encapsulating logic this way, you are practicing Business As Code—turning abstract business rules into concrete, executable, and maintainable software components.
Let's see how simple it is to define and execute an atomic action. Imagine we want to create a tool for processing payments. With action.do, you define it directly in your codebase.
import { Do } from '@do-sdk/core';
// Define an atomic action to process a payment
const processPayment = Do.action('process-payment', {
// 1. Define a clear input contract
inputs: {
customerId: 'string',
amount: 'number',
},
// 2. Encapsulate the core business logic
handler: async ({ inputs, context }) => {
// Connect to a payment provider like Stripe
console.log(`Processing payment of $${inputs.amount} for ${inputs.customerId}`);
// ... your secure payment gateway logic here ...
// 3. Return a predictable, structured result
return { success: true, transactionId: `txn_${context.runId}` };
},
});
// 4. 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:
While an action.do might look like a standard serverless function, it's purpose-built for the world of microservices and agentic systems.
By providing AI agents with a toolkit of these atomic actions, you shift their responsibility from how to perform a task to which task to perform. The agent focuses on decision-making, while action.do ensures flawless execution.
Are you ready to build more reliable automations? Transform your business logic into intelligent, executable tools and empower your workflows to operate at the next level.
What is an 'atomic action' on the .do platform?
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.
How is an action.do different from a standard serverless function?
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.
Can actions call other actions?
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.
What kind of logic can I run inside an action.do?
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.
How are inputs and secrets handled in an action?
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.