Unlock the power of agentic workflows on the .do platform by starting with the fundamental building block: the function.do. Think of function.do as the atomic units of your business logic, encapsulating a single, specific action. This guide will walk you through creating your very first function.do and understanding its role in building sophisticated agentic workflows.
At its core, a function.do is a defined piece of executable code that performs a specific task within the .do platform. It's designed to be self-contained and reusable, making it easy to compose into larger, more complex operations. Instead of writing monolithic applications, you break down your business processes into these smaller, manageable function.do units.
This "atomic" approach offers several advantages:
The true power of function.do lies in their ability to encapsulate business logic. Whether it's processing an order, sending a notification, retrieving customer data, or interacting with an external API, each of these actions can be defined as a function.do.
Let's look at a simple example of a function.do written in TypeScript using the .do SDK. This function encapsulates the logic for creating a new service.
export const createService = agent(async (input: { name: string, description?: string }) => {
// Logic to create a new service
const newService = {
id: generateId(), // Assuming generateId is a helper function
name: input.name,
description: input.description || '',
createdAt: new Date()
};
console.log(`Created service: ${newService.name}`);
return newService;
});
In this example:
This function.do is a perfect example of an atomic unit. It does one thing: creates a service. It doesn't handle fetching external data, notifying users, or any other unrelated task. These would be handled by other function.do.
Once you have defined your individual function.do, the .do platform allows you to compose them into sophisticated agentic workflows. Imagine a workflow for onboarding a new customer. This could involve a sequence of function.do:
Each of these steps is an independent function.do, but they are orchestrated together to form the complete onboarding process. This modular approach makes your workflows flexible, resilient, and easier to manage.
Ready to build your first atomic unit of business logic on the .do platform?
By starting with the fundamental concept of function.do and embracing the atomic approach, you set the stage for building powerful, scalable, and maintainable agentic applications on the .do platform.