Automating business processes can be complex. You're often juggling APIs, managing state, handling errors, and trying to chain together multiple services into a coherent flow. What if you could define these complex processes with the same tools you use to build your applications? What if your business logic could live as version-controlled, testable, and deployable code?
This is the core idea behind Business-as-Code, and with the .do SDK, it's never been easier to achieve.
The .do SDK is a powerful Typescript library designed for building Agentic Workflows. It provides developers with the tools to turn complex processes into simple, powerful Services-as-Software. In this tutorial, we'll walk you through building and executing your first agentic workflow—a simple customer onboarding process—in just a few minutes.
Think of an agentic workflow as a blueprint for a business process, defined entirely in code. Instead of a simple script, it’s a series of explicit steps (e.g., validate.email, create.user.profile) executed by an "Agent". This agent is responsible for running the workflow, managing its state, and ensuring the process completes successfully. This approach makes your automation robust, scalable, and easy to reason about.
Before we start, make sure you have the following installed:
Let's start by creating a new project directory and initializing it with npm and TypeScript.
# Create and navigate into your new project directory
mkdir my-first-agent && cd my-first-agent
# Initialize a new Node.js project
npm init -y
# Install the .do SDK core and TypeScript
npm install @do-sdk/core typescript
# Create a typescript configuration file
npx tsc --init
Now, create a new file named index.ts. This is where we'll define our workflow.
The first step in creating an agentic workflow is to define the workflow itself. A Workflow is a named collection of ordered steps. Each step represents a distinct action in your business process.
Open index.ts and add the following code:
import { Agent, Workflow } from '@do-sdk/core';
// Define a workflow with multiple steps
const onboardCustomer = new Workflow({
name: 'customer.onboard',
steps: [
{ do: 'validate.email' },
{ do: 'create.user.profile' },
{ do: 'send.welcome.email' },
],
});
Let's break this down:
Now that we have a workflow blueprint, we need an Agent to execute it. An Agent is the runtime that takes a workflow definition and a data payload and carries out the steps.
In the same index.ts file, add the code to create and run your agent:
// Create an agent capable of executing the workflow
const agent = new Agent({ workflows: [onboardCustomer] });
// Define an async function to execute the workflow
async function run() {
console.log('Executing workflow: customer.onboard...');
const result = await agent.execute('customer.onboard', {
email: 'new.user@example.com',
name: 'Jane Doe',
});
console.log('Workflow finished with result:', result);
}
// Run the function
run();
Here's what's happening:
Your complete index.ts file should now look like this:
import { Agent, Workflow } from '@do-sdk/core';
// 1. Define a workflow with multiple steps
const onboardCustomer = new Workflow({
name: 'customer.onboard',
steps: [
{ do: 'validate.email' },
{ do: 'create.user.profile' },
{ do: 'send.welcome.email' },
],
});
// 2. Create an agent to execute the workflow
const agent = new Agent({ workflows: [onboardCustomer] });
// 3. Execute the workflow via the agent
async function run() {
console.log('Executing workflow: customer.onboard...');
const result = await agent.execute('customer.onboard', {
email: 'new.user@example.com',
name: 'Jane Doe',
});
console.log('Workflow finished with result:', result);
}
// Run the function
run();
To run your first agentic workflow, you'll need ts-node. If you don't have it, install it globally (npm install -g ts-node) or as a dev dependency. Then, execute the file from your terminal:
npx ts-node index.ts
You'll see output showing the agent successfully executing the workflow. Congratulations! You've just built your first piece of Business-as-Code.
This simple example demonstrates the core concepts of the .do SDK. The real power comes when you deploy this code. The .do platform automatically takes your deployed agent and exposes its workflows as secure, scalable API endpoints. Your customer.onboard workflow instantly becomes a Service-as-Software that can be called from anywhere, without you ever having to configure a server, manage infrastructure, or set up API gateways.
What is the .do SDK?
The .do SDK is a Typescript library that allows developers to programmatically define, manage, and execute agentic workflows. It's the primary tool for building Business-as-Code on the .do platform.
Who is the SDK for?
The SDK is designed for developers who want to automate complex business processes, integrate services, and deliver them as robust, version-controlled software. If you know Typescript, you can start building powerful agents immediately.
How do I get started with the SDK?
Getting started is simple. Install the package via npm (npm install @do-sdk/core), import the necessary modules, and start defining your first agent and workflow. Check our documentation for comprehensive guides.
Can I test my workflows locally?
Yes, the .do SDK comes with a local testing environment and mocking utilities. This allows you to develop and debug your workflows entirely on your local machine before deploying them to the .do cloud platform.
How do my workflows become APIs?
Once you deploy a workflow using the SDK, the .do platform automatically exposes it as a secure, scalable API endpoint. This transforms your business logic (Business-as-Code) into a consumable service (Service-as-Software) without any extra configuration.