Are you looking to integrate the power of the .do platform's agentic workflows into your existing applications? The .do SDK provides a robust and intuitive way to interact with the platform, enabling you to initiate workflows and, importantly, retrieve and process their results. This blog post will guide you through extracting valuable output from your .do workflow executions using the SDK.
The .do platform excels at orchestrating complex tasks through its agentic AI and business-as-code approach. Whether you're automating lead qualification, generating reports, or performing complex data analysis, these workflows produce results that are crucial for the next steps in your process. The .do SDK acts as your bridge to seamlessly access these outputs.
Once you've initiated a workflow using the .do SDK, you'll typically receive a workflow execution ID. This ID is your key to monitoring the workflow's progress and ultimately fetching its results.
Here's a simplified example demonstrating how you might check the status of a workflow and retrieve its results once it's completed:
import { DoSDK } from '@do/sdk';
const sdk = new DoSDK({
apiKey: 'YOUR_API_KEY',
});
async function getWorkflowResults(executionId: string) {
try {
// Poll for workflow completion (you might implement a more sophisticated polling mechanism)
let status = 'running';
let results = null;
while (status === 'running') {
const executionStatus = await sdk.workflows.getExecutionStatus(executionId);
status = executionStatus.status;
console.log(`Workflow ${executionId} status: ${status}`);
if (status === 'running') {
await new Promise(resolve => setTimeout(resolve, 5000)); // Wait for 5 seconds before checking again
} else if (status === 'completed') {
results = await sdk.workflows.getExecutionResults(executionId);
} else if (status === 'failed') {
console.error(`Workflow ${executionId} failed.`);
break;
}
}
if (results) {
console.log('Workflow Results:', results);
// Process the results as needed
return results;
}
} catch (error) {
console.error(`Error fetching workflow results for ${executionId}:`, error);
throw error; // Re-throw or handle the error
}
}
// Example usage (assuming you have an executionId from initiating a workflow)
// const myExecutionId = 'your_workflow_execution_id';
// getWorkflowResults(myExecutionId);
Explanation:
The results object returned by sdk.workflows.getExecutionResults() will contain the data produced by your workflow. The exact format will vary based on your workflow's configuration. You'll need to understand the expected output structure of your specific workflow to effectively process this data within your application.
Examples of how you might process the results include:
If you're new to the .do SDK, getting started is straightforward:
npm install @do/sdk
# or
yarn add @do/sdk
The .do SDK empowers you to deeply integrate and extend the capabilities of the .do platform. By leveraging its methods for fetching workflow results, you can seamlessly incorporate the output of your agentic processes into your applications, unlocking new levels of automation and functionality. Start experimenting with the .do SDK today and see how it can transform your workflows and integrations!
Keywords: do platform, do sdk, software development kit, api integration, workflow automation, agentic ai, business as code, services as software