Your business services, built as code on the .do platform, are powerful engines for automation and value delivery. But every engine needs fuel and produces results. In the world of .do workflows, this is managed through carefully defined Input, Output, and State. Understanding how to effectively handle data is crucial for building robust, reliable, and valuable business services.
Let's dive into the core concepts of data flow within your .do workflows.
Every business service needs information to perform its task. Think of the input as the parameters or data required to execute your workflow. With .do, you define this input clearly when creating your service. This ensures that when someone (another system, a user, or even another workflow) calls your service, they provide the necessary information.
Consider a workflow designed to generate an invoice. Its input needs to include details like the customer information (name, email), and a list of items with quantities and prices. This is precisely what you see in our code example:
import { Workflow } from "@dotdo/sdk";
const myWorkflow = new Workflow("generateInvoice");
myWorkflow.setInput({
customer: {
name: "Acme Corp",
email: "info@acmecorp.com"
},
items: [
{ name: "Product A", quantity: 2, price: 100 },
{ name: "Product B", quantity: 1, price: 50 }
]
});
By explicitly defining the input structure, you create a clear contract for your service. This makes it easy to integrate with other systems and ensures that your workflow receives the data it needs to operate correctly.
Once your workflow has completed its tasks, it should produce a result. This is the Output of your service. The output could be anything from a generated document, a status update, a set of calculated values, or even just confirmation that the task was completed successfully.
The .do platform allows you to define and structure the output of your workflow. This output is then returned to the caller, providing the valuable result of your service execution. In our invoice generation example, the output might be a link to the generated invoice PDF and a confirmation message.
By defining your output, you make your service easily consumable and its results readily available for subsequent actions or systems. The result variable in our code example would hold this output after the workflow runs.
Beyond input and output, complex workflows often need to maintain information throughout their execution. This is where State comes in. State is data that persists within a single workflow run. It allows different steps or agents within the workflow to share and update information as the process unfolds.
Imagine a workflow for onboarding a new customer. The state could hold information like the customer's progress through the onboarding steps, temporary data gathered during different stages, or flags indicating whether certain actions have been completed.
State is particularly useful in workflows involving sequential steps, conditional logic, or interactions between multiple AI agents. It provides a dynamic memory for your workflow, enabling it to make informed decisions and adapt based on the data it has collected during the current execution.
Effectively managing input, output, and state is fundamental to building valuable and reliable business services with .do.
By mastering these data-handling concepts, you can leverage the power of the .do platform to build, automate, and deliver sophisticated business services as code. Ready to start transforming your business processes? Explore the capabilities of developer.services.do and unleash the power of your developer services.
Empower Your Business with .do. Build, automate, and deliver valuable business services as code using our AI-powered Agentic Workflow Platform.