Page cover

Input Templating System

ℹ️ Note: Workflow nodes generate output fields at runtime. The templating system manages these dynamic values and their relationships between nodes.

Block Definition Model

Block Structure

interface Block {
  // Input field definitions
  inputs: {
    [key: string]: {
      type: string;
      required: boolean;
      description: string;
    };
  };
  
  // Output field definitions
  outputs: {
    [key: string]: {
      type: string;
      description: string;
    };
  };
}

Frontend Implementation

Workflow Hierarchy

The system uses a graph-based structure to manage node relationships:

  1. Field Discovery

    • Performs BFS (Breadth-First Search) on ascendant nodes

    • Collects available output fields

    • Maps fields to their source nodes

  2. Template Generation

    • Creates template strings for each field

    • Format: {{node_id-value}}

    • Example: {{node-123-output_field}}

Backend Processing

Kafka Workflow Task

Template Resolution Process

  1. Value Collection

  1. Template Replacement

Implementation Example

Sample Workflow

⚠️ Warning: Remember to handle cases where template values might not be available yet, as nodes execute asynchronously.

Best Practices

Tips for Template Usage

  1. Unique Node IDs

    • Ensure node IDs are unique across the workflow

    • Use descriptive IDs for better debugging

  2. Error Handling

    • Validate template syntax before execution

    • Handle missing or undefined values gracefully

  3. Performance

    • Cache template resolution results when possible

    • Minimize template string parsing operations

Last updated