In today's fast-paced development landscape, the pressure is on to do more with less. We're constantly looking for ways to streamline operations, reduce manual effort, and build more intelligent applications. While traditional automation has its place, it often falls short when faced with complex, multi-step processes that require reasoning and adaptation.
Enter the new era of autonomous digital workers.
Meet Lena.do, a capable autonomous agent designed to handle the complex business operations you'd normally assign to a person. By delegating tasks to Lena, you transform manual processes into scalable, reliable Services-as-Software, all accessible through a simple API.
This guide is a hands-on tutorial for developers. We'll walk you through setting up your environment, authenticating with the .do platform, and delegating your first complex task to Lena. By the end, you'll see just how easy it is to integrate autonomous capabilities directly into your applications.
Before we dive into the code, let's clarify what makes Lena different from a standard automation script.
Traditional automation typically follows a rigid, predefined path. If it encounters an unexpected error or a change in the workflow, it often breaks. An autonomous worker like Lena operates on a different level. This is what's known as an agentic workflow:
You can delegate any well-defined business process, from complex customer onboarding and financial report generation to supply chain logistics and lead qualification. If you can describe the end goal, Lena can work to make it happen.
Let's get our hands dirty and delegate a common business task: onboarding a new enterprise customer.
First, let's create a new project directory and initialize a Node.js project.
mkdir lena-project
cd lena-project
npm init -y
Next, we need to install the .do SDK, which provides the tools to communicate with Lena.
npm install @do-sdk/core
For security best practices, we'll use an environment variable to store our API key. Let's install dotenv to manage this easily.
npm install dotenv
Create a file named .env in your project root and add your API key:
DO_API_KEY="your_api_key_here"
Finally, create your main application file, index.js.
touch index.js
Now, open index.js and let's write some code. The first thing we need to do is import the necessary libraries and create an authenticated client to interact with Lena.
// index.js
require('dotenv').config();
const { createDoClient } = require('@do-sdk/core');
// Authenticate and create a client for Lena
const lena = createDoClient('lena.do', {
apiKey: process.env.DO_API_KEY
});
console.log('Successfully connected to Lena!');
This code snippet initializes the client by pointing it to the lena.do agent and authenticating with the API key from your .env file.
This is where the magic happens. We're going to define an async function to handle the customer onboarding process. Instead of writing dozens or hundreds of lines of code to interact with CRMs, billing systems, and email services, we'll simply delegate the entire objective to Lena.
Let's add the core logic to index.js.
import { createDoClient } from '@do-sdk/core';
// Authenticate and create a client for Lena
const lena = createDoClient('lena.do', {
apiKey: process.env.DO_API_KEY
});
// Define the data for the new customer
const newCustomer = {
name: 'Innovate Corp',
email: 'contact@innovatecorp.com',
};
// Delegate a complex task to Lena with a clear objective
const onboardNewCustomer = async (customerData) => {
console.log(`Delegating onboarding for ${customerData.name}...`);
try {
const result = await lena.delegate('Fully onboard new enterprise customer account', {
companyName: customerData.name,
contactEmail: customerData.email,
requestedPlan: 'enterprise_v2-premium',
source: 'API-Trigger'
});
console.log('--- Task Result ---');
console.log('Onboarding Status:', result.status);
console.log('Summary:', result.summary);
// The result can contain structured data, like an ID for the new record
if (result.onboardingId) {
console.log('Onboarding ID:', result.onboardingId);
}
return result;
} catch (error) {
console.error('An error occurred while delegating the task:', error);
}
};
// Run the function
onboardNewCustomer(newCustomer);
Let's break down the lena.delegate() call:
Save your index.js file and run it from your terminal:
node index.js
You should see an output similar to this:
Delegating onboarding for Innovate Corp...
--- Task Result ---
Onboarding Status: completed
Summary: Customer 'Innovate Corp' was successfully onboarded. CRM record created (ID: 789123), welcome email sent, and enterprise plan provisioned.
Onboarding ID: B-NPRD-12345
That's it! With one API call, you've kicked off a complex business automation workflow. Lena handled the orchestration behind the scenes, and you received a clean, simple result.
By integrating Lena, you're not just automating a task; you're fundamentally changing how you build and scale your operations. Complex processes are no longer manual bottlenecks or brittle scripts. They become robust, intelligent services you can call on demand. This is the future of Services-as-Software.
Imagine embedding this power anywhere in your stack:
The possibilities are limitless. All you need to do is define the objective.
Delegate. Automate. Innovate.
Ready to add an autonomous digital worker to your team? Get your API key from lena.do and transform your business operations today.