E-commerce order processing is a classic example of a business-critical workflow that is deceptively complex. A single order can trigger a cascade of events: payment processing, inventory updates, database entries, customer notifications, and shipping logistics. When these steps are bundled into a single monolithic API endpoint or a loose chain of webhooks, a single point of failure—a payment gateway timeout, a brief database outage—can leave the entire system in an inconsistent state. The result? Lost revenue, frustrated customers, and frantic manual cleanup for your operations team.
There is a better way. By deconstructing complex processes into their fundamental components, we can build systems that are not just powerful, but also resilient, scalable, and transparent. This is the core principle behind the .do Agentic Workflow Platform: building with atomic actions as code.
This post will walk you through how to transform a fragile, traditional order processing flow into a robust, scalable service using .do.
Consider a typical e-commerce order workflow built with a standard API approach:
What happens if the send-email service is down? The customer is charged and the inventory is updated, but they never receive a confirmation. What if the inventory update fails due to a deadlock? The customer is charged, but no order is officially recorded. These partial failures create data integrity nightmares.
Instead of one large, brittle function, the .do approach is to break the process down into its smallest, indivisible units of work. We call these atomic actions. Each action is a self-contained, reusable piece of business logic that is guaranteed to either succeed completely or fail cleanly without side effects.
For our e-commerce order, the workflow is composed of these distinct atomic actions:
This composability is the foundation of powerful and reliable workflow automation.
With .do, you define your business logic directly in code. You focus purely on the task at hand, while the platform handles the heavy lifting of state management, retries, logging, and audit trails.
Here’s how you might define the send-order-confirmation-email action. Notice how it's dedicated to a single task and contains clear success/failure logic.
This isn't just a function—it's a managed, stateful component. Unlike a standard API endpoint, this .do Action has built-in features:
Once defined, these atomic actions become the building blocks for your complete business process automation. You don't need complex orchestration code or a separate workflow engine. You can easily chain actions together to model the entire order process.
A workflow on .do might look like this:
If the send-order-confirmation-email Action fails (e.g., the email provider's API is temporarily down), the .do platform will automatically retry it according to your configuration. The rest of the workflow is unaffected. The integrity of the order is never compromised by a failure in a non-critical, downstream step. This is the power of an agentic workflow, where stateful components handle their own execution logic.
By shifting from monolithic functions to a composable model of atomic actions, you gain significant advantages:
Stop wrestling with fragile scripts and complex orchestration tools. Start building reliable, scalable, and auditable business workflows with atomic actions as code.
Ready to build your first fault-tolerant workflow? Explore action.do and define your first Action today.
import { Action, client } from '@do-sdk/core';
// Define an atomic action as code
const sendOrderConfirmationEmail = new Action({
name: 'send-order-confirmation-email',
handler: async (inputs: { orderId: string; userId: string }) => {
const order = await db.orders.find(inputs.orderId);
const user = await db.users.find(inputs.userId);
if (!order || !user) {
throw new Error('Order or User not found.');
}
await email.send({
to: user.email,
subject: `Your order #${order.id} is confirmed!`,
body: `Hi ${user.name}, thanks for your purchase!`
});
return { success: true, messageId: '...' };
}
});