In today's data-centric world, the most valuable business insights are locked away in data warehouses like Snowflake, Google BigQuery, and Amazon Redshift. While your business runs on this data, traditional automation platforms often can't access it, leading to rigid, uninformed workflows. It's time to change that.
What if your automation could not only execute tasks but also make intelligent, data-driven decisions in real-time? With the .do Agentic Workflow Platform, you can build powerful agents that connect directly to your data sources. This post will demonstrate how to leverage the .do SDK to create agents that query your data warehouse, unlocking a new level of sophisticated, context-aware automation.
Integrating your automation layer with your data layer isn't just about convenience; it's a strategic advantage. When your workflows can read and react to the data in your warehouse, you move from simple, brittle scripts to intelligent, adaptive systems.
Here's what you unlock:
The power of the .do platform lies in its "agentic" architecture. An agent is a specialized, reusable component designed to interact with a specific system or perform a focused task. Using our Software Development Kit (SDK), you can easily build your own custom agents.
A Data Warehouse Agent is a component you build whose sole purpose is to:
By building this logic once, you create a powerful, reusable developer tool that any workflow in your organization can use.
Let's walk through a practical example of creating an agent that connects to Snowflake using the .do TypeScript SDK. The principles are nearly identical for BigQuery, Redshift, or any other SQL database.
npm install @do-platform/sdk snowflake-sdk
# Or yarn add @do-platform/sdk snowflake-sdk
The agent is just a function that encapsulates the connection and query logic. We'll use environment variables to store our credentials securely—never hardcode them!
// src/agents/snowflake-agent.ts
import * as snowflake from 'snowflake-sdk';
interface QueryInput {
query: string;
params?: any[];
}
// This function is our reusable agent logic
export async function runSnowflakeQuery(input: QueryInput): Promise<any[]> {
const connection = snowflake.createConnection({
account: process.env.SNOWFLAKE_ACCOUNT!,
username: process.env.SNOWFLAKE_USER!,
password: process.env.SNOWFLAKE_PASSWORD!,
warehouse: process.env.SNOWFLAKE_WAREHOUSE!,
database: process.env.SNOWFLAKE_DATABASE!,
schema: process.env.SNOWFLAKE_SCHEMA!,
});
try {
// Attempt to connect to Snowflake
await new Promise((resolve, reject) => {
connection.connect((err, conn) => {
if (err) {
console.error('Unable to connect to Snowflake:', err.message);
reject(err);
} else {
console.log('Successfully connected to Snowflake.');
resolve(conn);
}
});
});
// Execute the query
const statement = await new Promise<snowflake.Statement>((resolve, reject) => {
connection.execute({
sqlText: input.query,
binds: input.params,
complete: (err, stmt, rows) => {
if (err) {
console.error('Failed to execute statement:', err.message);
reject(err);
} else {
console.log(`Query successful. Fetched ${rows?.length} rows.`);
resolve(stmt);
}
},
});
});
// Stream the results into an array
const rows = await new Promise<any[]>((resolve, reject) => {
const stream = statement.streamRows();
const results: any[] = [];
stream.on('error', (err) => reject(err));
stream.on('data', (row) => results.push(row));
stream.on('end', () => resolve(results));
});
return rows;
} catch (error) {
console.error('An error occurred during the Snowflake query:', error);
throw error; // Re-throw to allow the workflow to handle the failure
} finally {
// Ensure the connection is always destroyed
if (connection.isUp()) {
connection.destroy((err) => {
if (err) {
console.error('Failed to disconnect from Snowflake:', err.message);
}
});
}
}
}
Now that we have our agent logic, we can import and use it within a larger automated process defined with the .do SDK.
Let's imagine a workflow for qualifying new enterprise customers.
// src/workflows/customer-qualification.ts
import { Do } from '@do-platform/sdk';
import { runSnowflakeQuery } from '../agents/snowflake-agent';
const doClient = new Do({
apiKey: process.env.DO_API_KEY,
});
async function qualifyNewCustomer(email: string) {
try {
// Step 1: Query Snowflake to get user data from our other products
const customerDataRows = await runSnowflakeQuery({
query: 'SELECT LIFETIME_VALUE, COMPANY_SIZE FROM dim_customers WHERE EMAIL = ?;',
params: [email],
});
if (customerDataRows.length === 0) {
console.log('New customer, no historical data found.');
// Proceed with standard onboarding...
return;
}
const customerData = customerDataRows[0];
const isHighValue = customerData.LIFETIME_VALUE > 10000 && customerData.COMPANY_SIZE > 500;
// Step 2: Run a .do workflow based on the data
const result = await doClient.workflows.run({
name: isHighValue
? 'enterprise-customer-onboarding'
: 'standard-customer-onboarding',
input: {
email: email,
source: 'DataWarehouseQualified',
},
});
console.log(`Started workflow '${result.workflowName}' with Run ID: ${result.runId}`);
return result;
} catch (error) {
console.error('Failed to run customer qualification workflow:', error);
}
}
In this example, our script acts as the orchestrator. It calls our custom Snowflake agent, makes a decision based on the returned data, and then triggers the appropriate workflow using the .do SDK. This seamless API integration makes your code the single source of truth for your business logic.
By bridging the gap between your applications and your data warehouse, you transform your automation from a simple task-doer into an intelligent decision-maker. The .do platform and our official SDKs provide all the developer tools you need to build, run, and scale these sophisticated agentic workflows.
Ready to unlock the power of your data?
What is the .do SDK?
The .do Software Development Kit (SDK) is a set of tools, libraries, and documentation that allows developers to easily integrate the .do agentic workflow platform directly into their own applications.
Which programming languages are supported?
We provide official SDKs for popular languages like TypeScript/JavaScript, Python, and Go. Check our developer documentation for the most up-to-date list and community-supported libraries.
Is the SDK free to use?
Yes, our SDKs are free to download and use. Usage of the underlying .do platform is subject to our standard pricing plans, which are based on workflow executions and agent usage.