Learn the fundamentals of building AI workflows. Understand how nodes, edges, execution order, and data flow work together to create powerful automation.
A workflow is a visual representation of an automated process. In TopFlow, workflows are made up of nodes (boxes that perform actions) connected by edges (arrows that show data flow).
Think of it like a flowchart for AI automation:
Every TopFlow workflow has three core components:
12 node types available:
Node properties:
Edges connect nodes and determine:
Edge structure:
{
id: "edge-1",
source: "node-start", // Which node sends data
target: "node-textModel", // Which node receives data
sourceHandle: "true" // Optional: for conditional branching
}A workflow is a directed acyclic graph (DAG):
{
nodes: [
{ id: "start", type: "start", data: { input: "Analyze security logs" } },
{ id: "text", type: "textModel", data: { model: "gpt-4" } },
{ id: "end", type: "end", data: {} }
],
edges: [
{ id: "e1", source: "start", target: "text" },
{ id: "e2", source: "text", target: "end" }
]
}Understanding how TopFlow executes workflows is key to building effective automation.
TopFlow automatically determines execution order using topological sorting:
Sequential: Nodes execute one at a time in topological order.
Conceptual parallelism: If multiple nodes have all dependencies met, they could run in parallel. However, TopFlow currently executes them sequentially for simplicity and predictability.
Conditional nodes have two output handles:
// Conditional node checks severity
condition: "output.includes('CRITICAL')"
// Two edges from this node:
{ source: "conditional", target: "alert-slack", sourceHandle: "true" } // High severity
{ source: "conditional", target: "log-only", sourceHandle: "false" } // Normal severityOnly matching edges are followed. If condition is true, only the "true" edge executes. The "false" branch is skipped entirely.
Understanding how data moves through your workflow is essential for building complex automation.
Access upstream outputs using $input1, $input2, etc.
When a node receives multiple inputs, they're numbered by the X position of source nodes (left to right):
// Node "merge" receives two inputs: // - From node "fetch-data" (X: 100) // - From node "user-prompt" (X: 200) // In the merge node's prompt: "Combine this data: $input1 with user request: $input2" // Runtime replacement: "Combine this data: [API response] with user request: [user input]"
Where you can use variables:
input1, input2 variablesCommon transformation patterns:
// JavaScript node const data = JSON.parse(input1) return data.threats.filter(t => t.severity === "HIGH")
// Prompt node Analyze these security events: $input1 Provide: severity, affected systems, recommended actions
// Structured Output node with Zod schema
{
threatLevel: z.enum(["LOW", "MEDIUM", "HIGH", "CRITICAL"]),
affectedSystems: z.array(z.string()),
recommendations: z.array(z.string())
}Learn these proven patterns to solve common automation challenges.
Use case: Security log analysis, market research, data enrichment
severity === "CRITICAL"Use case: Alert routing, approval workflows, data filtering
Use case: Data enrichment, multi-modal analysis, progressive refinement
TopFlow validates your workflow before execution to catch errors early.
TopFlow assigns a grade based on errors and warnings:
Follow these guidelines to build robust, secure, and maintainable workflows.
Now that you understand the fundamentals, dive deeper into specific topics: