In modern software development, automation is key. From onboarding new customers to processing complex data pipelines, businesses rely on orchestrating dozens of tasks. But as this logic grows, it can become tangled, hard to manage, and difficult to change. This is where agentic workflows come in—a powerful way to define, run, and manage your business logic as code.
The .do Agentic Workflow Platform provides the engine for this new paradigm. And with the official .do TypeScript SDK, you can seamlessly integrate this power directly into your Node.js and TypeScript applications. This guide will walk you through every step, from setting up your project to running your first workflow.
Before we dive into the code, let's briefly touch on the "why." The .do platform allows you to define complex, multi-step processes involving AI agents, human-in-the-loop decisions, and third-party API calls. These "agentic workflows" live on the .do platform, where they can be monitored, versioned, and executed reliably.
The Software Development Kit (SDK) is your bridge to this platform. It provides a simple, elegant interface in your native language, so you don't have to deal with raw HTTP requests. You can trigger workflows, pass in data, and handle results, all from within your application's codebase.
To follow along, you'll need a few things:
Your API Key is essential for authenticating with the .do platform.
Security Best Practice: Never hardcode your API key in your source code. We strongly recommend using environment variables.
Let's initialize a new project and install the necessary dependencies. Open your terminal and run the following commands:
# Create a new project directory
mkdir do-sdk-guide
cd do-sdk-guide
# Initialize a Node.js project
npm init -y
# Install the .do SDK and dotenv for managing environment variables
npm install @do-platform/sdk dotenv
# Install TypeScript as a development dependency
npm install -D typescript @types/node
# Initialize a TypeScript configuration file
npx tsc --init
Next, create a .env file in your project's root directory to store your API key:
.env
DO_API_KEY="your_api_key_here"
Finally, create a source file for our code, src/index.ts.
The core of the SDK is the client instance. It's your gateway to interacting with the entire .do platform.
In your src/index.ts file, let's import the necessary modules and create the client.
// src/index.ts
import { Do } from '@do-platform/sdk';
import * as dotenv from 'dotenv';
// Load environment variables from the .env file
dotenv.config();
// 1. Initialize the SDK Client
const doClient = new Do({
apiKey: process.env.DO_API_KEY,
});
console.log('SDK Client Initialized!');
This code snippet does two things:
Now for the exciting part: triggering a workflow. For this example, let's assume you have a workflow defined in your .do dashboard named customer-onboarding-workflow. This workflow is designed to take new customer data as input.
We can trigger it using the doClient.workflows.run() method.
// src/index.ts
import { Do } from '@do-platform/sdk';
import * as dotenv from 'dotenv';
dotenv.config();
const doClient = new Do({
apiKey: process.env.DO_API_KEY,
});
// A sample customer data object
const newCustomer = {
name: 'Jane Doe',
email: 'jane.doe@example.com',
companySize: 50,
plan: 'Pro',
};
// 2. Define an async function to run the workflow
async function runCustomerOnboarding(customerData: any) {
console.log(`Starting workflow for ${customerData.email}...`);
try {
const result = await doClient.workflows.run({
// The unique name of your workflow in the .do platform
name: 'customer-onboarding-workflow',
// The data your workflow needs to execute
input: { customer: customerData },
// Optional: Wait for the workflow to complete before returning
// wait: true
});
console.log('Workflow successfully started!');
console.log('Run ID:', result.runId);
// If you used `wait: true`, result.output would contain the final result.
console.log('Full result:', result);
return result;
} catch (error) {
console.error('Failed to run workflow:', error);
}
}
// 3. Call the function
runCustomerOnboarding(newCustomer);
Let's break down the doClient.workflows.run() call:
To run your code, first compile the TypeScript to JavaScript and then execute it with Node:
# Compile TypeScript
npx tsc
# Run the compiled JavaScript
node dist/index.js
You should see output in your console confirming that the workflow has been started!
You've successfully integrated the .do platform into your TypeScript application! This is just the beginning. The SDK provides a comprehensive set of developer tools for powerful API integration. You can also:
For a complete list of capabilities, be sure to check out the official developer documentation on sdk.do.
Ready to build, automate, and innovate faster? Get your API key and start integrating your agentic workflows today.