In today's digital landscape, business doesn't happen in a vacuum. It's a complex dance between dozens of specialized applications: payment gateways, CRMs, marketing platforms, databases, and communication tools. The real power comes from making these services talk to each other. But anyone who has tried to build and maintain these connections knows the pain of brittle scripts and tangled code.
What if you could treat every piece of business logic—every external API call—as a clean, reusable, and robust building block?
This is the core principle behind action.do. We believe in "Business As Code"—transforming your operational logic into flawless, scalable, and observable atomic actions. These actions are the fundamental components for building powerful, AI-powered agentic workflows. Let's explore how you can use them to securely and reliably connect your workflows to the external services that power your business.
Before we connect to anything, let's clarify what we're building with. An atomic action is a self-contained, single-purpose function designed to perform one specific task perfectly.
Think of it as the ultimate microservice, but purpose-built for automation and agentic systems. Instead of a monolithic function that tries to do everything, you encapsulate each logical step. This modularity is the key to building automations that are easy to understand, maintain, and scale.
Theory is great, but code tells the real story. Let's break down how to create an atomic action that integrates with an external payment provider like Stripe.
import { Do } from '@do-sdk/core';
// Define an atomic action to process a payment
const processPayment = Do.action('process-payment', {
// 1. Define the API Contract with typed inputs
inputs: {
customerId: 'string',
amount: 'number',
},
// 2. Encapsulate the business logic in the handler
handler: async ({ inputs, context }) => {
// Connect to a payment provider like Stripe
console.log(`Processing payment of $${inputs.amount} for ${inputs.customerId}`);
// 3. securely call the external service (secrets managed by .do)
// const stripe = new Stripe(context.secrets.STRIPE_API_KEY);
// await stripe.charges.create(...);
// 4. Return a structured, predictable 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 dissect this process-payment action:
An atomic action is powerful on its own, but its true potential is unlocked when composed into a sequence. This is the essence of an agentic workflow.
A single action is designed to be atomic; it shouldn't call other actions directly. Instead, you use a workflow.do to orchestrate them. This enforces a clean separation of concerns and creates a visual, stateful process.
Imagine an e-commerce order fulfillment workflow:
Each step is a distinct, reliable action.do. The workflow manages the state, error handling, and data flow between them, turning discrete business tasks into a seamless, automated process.
While this example focuses on a payment provider, an action can encapsulate any piece of logic you can code. It's the universal adapter for your business operations.
You can create atomic actions to:
By encapsulating external service interactions within atomic actions, you're not just writing code; you're building a library of robust, reusable business capabilities. You're creating the building blocks for more intelligent, maintainable, and powerful business automation.
Ready to transform your business logic into flawless, automated workflows? Start building your first atomic action on the .do platform today.