Not everyone builds AI agents with a visual editor. Some developers prefer code—their IDE, their version control, their CI pipeline. For them, we built the AACFlow TypeScript SDK.
The visual editor is brilliant for exploration, prototyping, and collaboration. But production-grade agent deployment often demands programmatic control: define workflows as code, version them in Git, trigger them from CI/CD, embed them into existing Node.js applications. The SDK makes this possible.
What the SDK Does
The AACFlow TypeScript SDK is an npm package that lets you:
- Define workflows programmatically — blocks, connections, configurations, everything you can do in the visual editor, expressed in TypeScript
- Trigger executions — run workflows with input data and get results back
- Handle results — stream execution events, collect outputs, handle errors
- Manage workflows — list, get, update, delete workflows in your workspace via API
It's built on top of our public REST API with full type safety. Every input and output is validated with Zod schemas. Autocomplete in your IDE. Compile-time errors instead of runtime surprises.
import { AACFlow } from '@aacflow/ts-sdk'
const aacflow = new AACFlow({
apiKey: process.env.AACFLOW_API_KEY,
workspaceId: process.env.AACFLOW_WORKSPACE_ID,
})
// Define a workflowconst workflow = await aacflow.workflows.create({
name: 'Lead Qualification Pipeline',
blocks: [
{id: 'webhook_input',
type: 'input.webhook',
position: { x: 100, y: 100 },
config: {
triggerId: 'amocrm_new_lead',
},
},
{id: 'enrich_lead',
type: 'connector.dadata',
position: { x: 300, y: 100 },
config: {
query: '{{webhook_input.leadName}}',
},
},
{id: 'score_lead',
type: 'llm.chat',
position: { x: 500, y: 100 },
config: {
model: 'gpt-4o',
systemPrompt: 'You are a lead scoring specialist...',
userPrompt: 'Score this lead: {{enrich_lead.company}}...',
},
},
{id: 'route_lead',
type: 'logic.condition',
position: { x: 700, y: 100 },
config: {
condition: '{{score_lead.score}} > 80',
trueBranch: 'send_to_sales',
falseBranch: 'send_to_nurture',
},
},
],
connections: [
{ source: 'webhook_input', target: 'enrich_lead' },
{ source: 'enrich_lead', target: 'score_lead' },
{ source: 'score_lead', target: 'route_lead' },
],
})
// Trigger an executionconst execution = await aacflow.executions.run({
workflowId: workflow.id,
input: {
leadName: 'Иванов Иван',
leadPhone: '+7 (999) 123-45-67',
leadSource: 'website_form',
},
})
// Stream results in real-timefor await (const event of execution.stream()) {
console.log(`[${event.blockId}] ${event.type}: ${event.status}`)
}// Get final resultconst result = await execution.result()
console.log('Lead score:', result.outputs.score_lead.score)
console.log('Route:', result.outputs.route_lead.branch)



