Complex business processes—from generating user-specific reports to orchestrating marketing campaigns—are notoriously difficult to automate. They often become a tangled web of brittle scripts, microservices, and extensive boilerplate code. Managing the underlying infrastructure adds another layer of complexity, pulling focus away from what truly matters: delivering business value.
What if you could define that entire complex workflow as a series of simple, composable functions? What if you could execute it with a single API call and receive a guaranteed, typesafe result?
This is the promise of agentic workflows, and with Functions.do, it's a promise you can realize in minutes. Functions.do is a developer platform designed for reliable, typesafe function execution. It allows you to build sophisticated, multi-step processes without the overhead of traditional serverless frameworks.
This tutorial will guide you through building your first agentic workflow, transforming a high-level business task into a production-ready, automated API.
In a traditional program, the flow is linear and explicitly coded. An agentic workflow, however, involves one or more autonomous "agents" that can orchestrate tasks, make decisions, and use various tools (or functions) to achieve a complex goal. Think of it less as a script and more as a digital expert that you can delegate a high-level objective to.
For example, instead of writing code to individually call a database, a market analysis API, and a text-generation model, you could simply ask an agent to "create a business plan for a new SaaS product." The agent would then intelligently chain together the necessary functions to produce the final result.
This paradigm is incredibly powerful for automating business logic because it mirrors how humans solve problems: by breaking them down into smaller, manageable steps.
While you could build an agentic system from scratch, Functions.do provides a purpose-built framework that handles the hard parts, letting you focus on outcomes, not operations.
Let's build a practical agentic workflow. Our goal is to create an automated "Business Idea Generator" that takes a product concept and produces a foundational business model.
First, you'll need the Functions.do client library. You can install it via npm:
npm install functions.do
Next, you'll need an API key to authenticate your requests. You can get one from your Functions.do dashboard.
Let's start with a single, powerful function: generate/lean-canvas. This function is designed to take a product idea and generate a complete Lean Canvas, a strategic business plan template.
Here’s how you run it using the Functions.do TypeScript client:
import { Client } from 'functions.do';
// 1. Initialize the client with your API key
const fns = new Client({ apiKey: 'your_api_key_here' });
// 2. Define the typesafe input for our business function
const input = {
productName: 'Agentic Workflow Platform',
problem: ['Complex business processes are manual and error-prone.'],
customerSegments: ['Enterprise Developers', 'DevOps Teams']
};
// 3. Execute the function and get a reliable, typesafe result
async function generateBusinessModel() {
try {
const leanCanvas = await fns.run('generate/lean-canvas', input);
// The result is a fully-typed object
console.log('--- Lean Canvas Generated ---');
console.log(`Product: ${leanCanvas.productName}`);
console.log(`Unique Value Proposition: ${leanCanvas.uniqueValueProposition}`);
console.log(`Solution: ${leanCanvas.solution}`);
// Expected output for uniqueValueProposition might be:
// "The simplest way to deliver business services as software."
} catch (error) {
console.error("Failed to generate lean canvas:", error);
}
}
generateBusinessModel();
In this code, we aren't just calling a remote endpoint. We are executing a version-controlled, typesafe function. If we provided customerSegments as a string instead of an array of strings, Functions.do would immediately return a validation error, preventing a difficult-to-debug failure deep within the workflow.
A single function is powerful, but the real magic of agentic workflows lies in composition. Let's extend our agent to not only generate a business plan but also to create marketing copy based on that plan.
Imagine we have another function available: generate/marketing-copy. This function takes a value proposition and target audience to generate compelling ad copy.
We can chain these two functions together to create a more sophisticated workflow:
import { Client } from 'functions.do';
const fns = new Client({ apiKey: 'your_api_key_here' });
async function businessIdeaToAdCampaign() {
try {
// --- Step 1: Generate the core business model ---
console.log('Generating lean canvas...');
const leanCanvas = await fns.run('generate/lean-canvas', {
productName: 'Agentic Workflow Platform',
problem: ['Complex business processes are manual and error-prone.'],
customerSegments: ['Enterprise Developers', 'DevOps Teams']
});
console.log('✅ Lean canvas generated!');
console.log(`UVP: ${leanCanvas.uniqueValueProposition}`);
// --- Step 2: Use the output of the first function as input for the second ---
console.log('\nGenerating marketing copy...');
const marketingCopy = await fns.run('generate/marketing-copy', {
uniqueValueProposition: leanCanvas.uniqueValueProposition,
customerSegments: leanCanvas.customerSegments
});
console.log('✅ Marketing copy generated!');
console.log(`\n--- Your New Ad Campaign ---`);
console.log(`Headline: ${marketingCopy.headline}`);
console.log(`Body: ${marketingCopy.body}`);
} catch (error) {
console.error("Agentic workflow failed:", error);
}
}
businessIdeaToAdCampaign();
Just like that, we've created a multi-step agentic workflow. We defined a high-level goal ("create a business idea and generate ad copy"), and the platform handled the orchestration. We didn't have to write any glue code, manage state between steps, or provision any infrastructure. The entire complex process is now available as a single, repeatable, and reliable automated workflow.
You've just seen how easy it is to build a powerful agentic workflow with Functions.do. By leveraging simple, composable, and typesafe functions, you can automate complex business logic without getting bogged down in operational complexity. This is the future of serverless execution: a focus on high-level outcomes, backed by a reliable, intelligent platform.
Whether you're looking to automate data enrichment, generate reports, or orchestrate complex AI tasks, Functions.do provides the simplest path from idea to production-ready API.
Ready to build your own reliable, agentic workflows? Get started with Functions.do today and turn your complex business processes into simple, powerful APIs.