← Back to Home

Complete Examples

This section provides production-ready examples demonstrating complete Juggernaut implementations. All examples use the InputProcess API, Views SDK, and Plugins SDK.


Example 1: Market Evaluation Engine

Scenario: Automating market research and pricing analysis for expansion decisions. Based on the workflow described in the platform walkthrough.

Architecture Overview

4 sequential pipelines with 10 total steps. Input: raw market description. Output: strategic brief with financial model.

Process JSON Definition

{
  "name": "Market Evaluation Engine",
  "description": "Evaluates market expansion opportunities with financial forecasting and pricing strategy",
  "defaultModel": "openai-gpt-4",
  "defaultState": {
    "currencyCode": "USD",
    "riskThreshold": 0.7,
    "projectionYears": 5
  },
  "inputs": [
    {
      "name": "marketQuery",
      "type": "string",
      "description": "Raw market scenario description (e.g., 'Expand logistics operations into Philippines')",
      "required": true
    },
    {
      "name": "targetVertical",
      "type": "string",
      "description": "Primary industry vertical (e.g., logistics, fintech, manufacturing)",
      "required": true
    },
    {
      "name": "geographicMarket",
      "type": "string",
      "description": "Target geographic region or country",
      "required": true
    },
    {
      "name": "currencyContext",
      "type": "string",
      "description": "ISO currency code for financial calculations (e.g., USD, EUR, PHP)",
      "required": true
    }
  ],
  "pipelines": [
    {
      "name": "Market Intelligence",
      "description": "Parse raw input and gather structured market data",
      "type": "sync",
      "steps": [
        {
          "name": "Parse Market Query",
          "outputName": "structuredQuery",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "system",
              "content": "You are a market research analyst. Extract structured data from business expansion queries."
            },
            {
              "type": "user",
              "content": "Parse this market description: {{marketQuery}}. Target industry: {{targetVertical}}, Region: {{geographicMarket}}."
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Structured market analysis",
              "properties": {
                "marketSize": {
                  "type": "number",
                  "description": "Total addressable market (TAM) in millions USD"
                },
                "growthRate": {
                  "type": "number",
                  "description": "Annual market growth rate as decimal (e.g., 0.15 for 15%)"
                },
                "competitiveDensity": {
                  "type": "string",
                  "description": "Competitive landscape: low, medium, or high saturation"
                },
                "keyTrends": {
                  "type": "array",
                  "description": "List of 3-5 major market trends affecting entry",
                  "items": {
                    "type": "string",
                    "description": "Specific trend description with business impact"
                  }
                }
              }
            }
          }
        },
        {
          "name": "Enrich Market Data",
          "outputName": "enrichedData",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Enrich this market data with recent financial metrics, regulatory environment, and technology adoption rates: {{structuredQuery}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Enriched market intelligence",
              "properties": {
                "regulatoryBarriers": {
                  "type": "array",
                  "description": "Government or legal obstacles to entry",
                  "items": {
                    "type": "object",
                    "description": "Regulatory factor",
                    "properties": {
                      "type": {
                        "type": "string",
                        "description": "Category: licensing, compliance, ownership, etc."
                      },
                      "difficulty": {
                        "type": "string",
                        "description": "Barrier severity: low, medium, high"
                      },
                      "estimatedCost": {
                        "type": "number",
                        "description": "Cost to overcome in USD thousands"
                      }
                    }
                  }
                },
                "technologyReadiness": {
                  "type": "string",
                  "description": "Local tech infrastructure maturity: primitive, emerging, mature"
                },
                "talentAvailability": {
                  "type": "object",
                  "description": "Workforce analysis",
                  "properties": {
                    "availability": {
                      "type": "string",
                      "description": "Labor pool status: scarce, adequate, abundant"
                    },
                    "averageSalary": {
                      "type": "number",
                      "description": "Average annual salary USD for relevant roles"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Strategic Analysis",
      "description": "Evaluate attractiveness, pricing, risk, and positioning",
      "type": "async",
      "steps": [
        {
          "name": "Market Attractiveness Score",
          "outputName": "attractivenessScore",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Calculate market attractiveness (0-100) based on: {{enrichedData}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Attractiveness assessment",
              "properties": {
                "score": {
                  "type": "number",
                  "description": "Composite score 0-100, 70+ is attractive"
                },
                "factors": {
                  "type": "array",
                  "description": "Scoring breakdown",
                  "items": {
                    "type": "object",
                    "description": "Individual factor",
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "Factor category (market size, growth, competition)"
                      },
                      "weight": {
                        "type": "number",
                        "description": "Factor importance percentage"
                      },
                      "contribution": {
                        "type": "number",
                        "description": "Points contributed to total score"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        {
          "name": "Pricing Analysis",
          "outputName": "pricingModel",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Develop pricing strategy for {{targetVertical}} in {{geographicMarket}} using market data: {{structuredQuery}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Pricing strategy parameters",
              "properties": {
                "recommendedPrice": {
                  "type": "number",
                  "description": "Suggested unit price in {{currencyContext}}"
                },
                "priceRange": {
                  "type": "object",
                  "description": "Min/max viable prices",
                  "properties": {
                    "min": {
                      "type": "number",
                      "description": "Floor price maintaining 20% margin"
                    },
                    "max": {
                      "type": "number",
                      "description": "Ceiling price before demand elasticity drops"
                    }
                  }
                },
                "margin": {
                  "type": "number",
                  "description": "Expected gross margin as decimal"
                },
                "pricingStrategy": {
                  "type": "string",
                  "description": "Approach: penetration, skimming, or parity"
                }
              }
            }
          }
        },
        {
          "name": "Risk Assessment",
          "outputName": "riskProfile",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Assess operational, financial, and geopolitical risks for entering {{geographicMarket}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Comprehensive risk analysis",
              "properties": {
                "overallRisk": {
                  "type": "string",
                  "description": "Aggregate level: low, medium, high"
                },
                "riskScore": {
                  "type": "number",
                  "description": "Risk score 0-1 (1 = highest risk)"
                },
                "categories": {
                  "type": "array",
                  "description": "Risk breakdown by category",
                  "items": {
                    "type": "object",
                    "description": "Risk category",
                    "properties": {
                      "category": {
                        "type": "string",
                        "description": "Risk type: political, economic, operational, competitive"
                      },
                      "severity": {
                        "type": "number",
                        "description": "0-10 severity rating"
                      },
                      "probability": {
                        "type": "number",
                        "description": "Likelihood 0-1"
                      },
                      "mitigation": {
                        "type": "string",
                        "description": "Strategy to reduce this risk"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        {
          "name": "Competitive Positioning",
          "outputName": "positioning",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Recommend market positioning strategy for {{targetVertical}} market in {{geographicMarket}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Positioning strategy",
              "properties": {
                "recommendedPosition": {
                  "type": "string",
                  "description": "Market stance: leader, challenger, follower, niche"
                },
                "differentiation": {
                  "type": "string",
                  "description": "Unique value proposition vs competitors"
                },
                "targetSegments": {
                  "type": "array",
                  "description": "Priority customer segments",
                  "items": {
                    "type": "object",
                    "description": "Target segment",
                    "properties": {
                      "segment": {
                        "type": "string",
                        "description": "Customer segment name"
                      },
                      "priority": {
                        "type": "number",
                        "description": "Targeting priority 1-5"
                      },
                      "estimatedShare": {
                        "type": "number",
                        "description": "Expected market share percentage from this segment"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Forecasting and GTM",
      "description": "Financial modeling and go-to-market planning",
      "type": "sync",
      "steps": [
        {
          "name": "Financial Forecast",
          "outputName": "financialModel",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Build 5-year financial forecast using pricing: {{pricingModel}}, market data: {{structuredQuery}}, risk profile: {{riskProfile}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "5-year financial projection",
              "properties": {
                "revenueProjection": {
                  "type": "array",
                  "description": "Annual revenue forecast",
                  "items": {
                    "type": "object",
                    "description": "Yearly financials",
                    "properties": {
                      "year": {
                        "type": "number",
                        "description": "Year number 1-5"
                      },
                      "revenue": {
                        "type": "number",
                        "description": "Annual revenue USD thousands"
                      },
                      "expenses": {
                        "type": "number",
                        "description": "Operating expenses USD thousands"
                      },
                      "ebitda": {
                        "type": "number",
                        "description": "EBITDA USD thousands"
                      },
                      "growthRate": {
                        "type": "number",
                        "description": "YoY growth decimal"
                      }
                    }
                  }
                },
                "breakEvenMonth": {
                  "type": "number",
                  "description": "Month when cumulative profit turns positive"
                },
                "roi": {
                  "type": "number",
                  "description": "Return on investment percentage at year 5"
                },
                "capitalRequirements": {
                  "type": "object",
                  "description": "Funding needs",
                  "properties": {
                    "initial": {
                      "type": "number",
                      "description": "Startup capital USD thousands"
                    },
                    "workingCapital": {
                      "type": "number",
                      "description": "Ongoing working capital needs"
                    }
                  }
                }
              }
            }
          }
        },
        {
          "name": "Go-to-Market Strategy",
          "outputName": "gtmPlan",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Create GTM plan for {{targetVertical}} in {{geographicMarket}} with positioning: {{positioning}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Go-to-market execution plan",
              "properties": {
                "phases": {
                  "type": "array",
                  "description": "Launch phases",
                  "items": {
                    "type": "object",
                    "description": "Phase details",
                    "properties": {
                      "phase": {
                        "type": "number",
                        "description": "Phase sequence 1-4"
                      },
                      "duration": {
                        "type": "string",
                        "description": "Timeframe (e.g., 'Months 1-3')"
                      },
                      "focus": {
                        "type": "string",
                        "description": "Primary objective"
                      },
                      "tactics": {
                        "type": "array",
                        "description": "Specific activities",
                        "items": {
                          "type": "string",
                          "description": "Tactic description"
                        }
                      },
                      "budget": {
                        "type": "number",
                        "description": "Phase budget USD thousands"
                      },
                      "milestones": {
                        "type": "array",
                        "description": "Success criteria",
                        "items": {
                          "type": "string",
                          "description": "Measurable milestone"
                        }
                      }
                    }
                  }
                },
                "kpis": {
                  "type": "array",
                  "description": "Key performance indicators",
                  "items": {
                    "type": "object",
                    "description": "KPI definition",
                    "properties": {
                      "metric": {
                        "type": "string",
                        "description": "KPI name"
                      },
                      "target": {
                        "type": "number",
                        "description": "Goal value"
                      },
                      "timeline": {
                        "type": "string",
                        "description": "Time to achieve"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Output Assembly",
      "description": "Compile final strategic brief",
      "type": "sync",
      "steps": [
        {
          "name": "Assemble Strategic Brief",
          "outputName": "strategicBrief",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "system",
              "content": "Synthesize all analyses into executive summary format"
            },
            {
              "type": "user",
              "content": "Create final brief incorporating: Attractiveness {{attractivenessScore}}, Pricing {{pricingModel}}, Risk {{riskProfile}}, Forecast {{financialModel}}, GTM {{gtmPlan}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Executive deliverable",
              "properties": {
                "executiveSummary": {
                  "type": "string",
                  "description": "One-paragraph recommendation with key rationale"
                },
                "marketScore": {
                  "type": "number",
                  "description": "Composite opportunity score 0-100"
                },
                "recommendation": {
                  "type": "string",
                  "description": "Final verdict: proceed_with_caution, enter_aggressively, do_not_enter, or wait_and_monitor"
                },
                "confidenceLevel": {
                  "type": "string",
                  "description": "Data reliability: high, medium, low"
                },
                "criticalAssumptions": {
                  "type": "array",
                  "description": "Key assumptions that must hold for success",
                  "items": {
                    "type": "object",
                    "description": "Assumption detail",
                    "properties": {
                      "assumption": {
                        "type": "string",
                        "description": "What is assumed"
                      },
                      "riskIfWrong": {
                        "type": "string",
                        "description": "Consequences if assumption fails"
                      },
                      "validationMethod": {
                        "type": "string",
                        "description": "How to verify this assumption"
                      }
                    }
                  }
                },
                "nextSteps": {
                  "type": "array",
                  "description": "Immediate action items if proceeding",
                  "items": {
                    "type": "object",
                    "description": "Action item",
                    "properties": {
                      "action": {
                        "type": "string",
                        "description": "Specific task"
                      },
                      "owner": {
                        "type": "string",
                        "description": "Responsible department"
                      },
                      "deadline": {
                        "type": "string",
                        "description": "Suggested timeframe (e.g., '30 days')"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

React Interface (Views SDK)

// components/MarketEvaluationDashboard.tsx
import { 
  JuggernautProvider, 
  useJuggernautJob, 
  JobStatus 
} from '@juggernautlabs/views';
import { 
  LineChart, 
  BarChart, 
  RadarChart, 
  ScoreCard, 
  RiskMatrix 
} from './charts';

interface MarketEvaluationOutputs {
  strategicBrief: {
    executiveSummary: string;
    marketScore: number;
    recommendation: string;
    confidenceLevel: string;
    criticalAssumptions: Array<{
      assumption: string;
      riskIfWrong: string;
      validationMethod: string;
    }>;
    nextSteps: Array<{
      action: string;
      owner: string;
      deadline: string;
    }>;
  };
  financialModel: {
    revenueProjection: Array<{
      year: number;
      revenue: number;
      ebitda: number;
    }>;
    breakEvenMonth: number;
    roi: number;
  };
  riskProfile: {
    overallRisk: string;
    riskScore: number;
    categories: Array<{
      category: string;
      severity: number;
      mitigation: string;
    }>;
  };
  attractivenessScore: {
    score: number;
    factors: Array<{
      name: string;
      contribution: number;
    }>;
  };
  pricingModel: {
    recommendedPrice: number;
    margin: number;
    pricingStrategy: string;
  };
}

function EvaluationContent() {
  const { jobData, isLoading } = useJuggernautJob<MarketEvaluationOutputs>();

  if (isLoading) return <LoadingState />;

  const { 
    strategicBrief, 
    financialModel, 
    riskProfile, 
    attractivenessScore,
    pricingModel 
  } = jobData.outputs;

  return (
    <div className="evaluation-dashboard">
      <header>
        <h1>Market Evaluation: {jobData.inputs.geographicMarket}</h1>
        <div className="meta">
          <JobStatus showCost={true} />
          <span className={`confidence ${strategicBrief.confidenceLevel}`}>
            Confidence: {strategicBrief.confidenceLevel}
          </span>
        </div>
      </header>

      <section className="executive-summary">
        <ScoreCard 
          score={strategicBrief.marketScore} 
          max={100}
          label="Market Opportunity Score"
          color={strategicBrief.marketScore > 70 ? 'green' : 'orange'}
        />
        <div className="recommendation">
          <h2>Recommendation: {strategicBrief.recommendation.replace(/_/g, ' ')}</h2>
          <p>{strategicBrief.executiveSummary}</p>
        </div>
      </section>

      <div className="grid">
        <section className="financials">
          <h3>5-Year Financial Projection</h3>
          <LineChart 
            data={financialModel.revenueProjection}
            lines={[
              { key: 'revenue', label: 'Revenue', color: '#2563eb' },
              { key: 'ebitda', label: 'EBITDA', color: '#16a34a' }
            ]}
          />
          <div className="metrics">
            <div>
              <label>Break-even</label>
              <value>Month {financialModel.breakEvenMonth}</value>
            </div>
            <div>
              <label>5-Year ROI</label>
              <value>{financialModel.roi}%</value>
            </div>
            <div>
              <label>Strategy</label>
              <value>{pricingModel.pricingStrategy}</value>
            </div>
          </div>
        </section>

        <section className="risk-analysis">
          <h3>Risk Profile</h3>
          <RiskMatrix 
            overallRisk={riskProfile.overallRisk}
            categories={riskProfile.categories}
          />
        </section>

        <section className="attractiveness">
          <h3>Attractiveness Breakdown</h3>
          <RadarChart 
            data={attractivenessScore.factors.map(f => ({
              axis: f.name,
              value: f.contribution
            }))}
          />
        </section>
      </div>

      <section className="action-plan">
        <h3>Immediate Next Steps</h3>
        <table>
          <thead>
            <tr>
              <th>Action</th>
              <th>Owner</th>
              <th>Timeline</th>
            </tr>
          </thead>
          <tbody>
            {strategicBrief.nextSteps.map((step, idx) => (
              <tr key={idx}>
                <td>{step.action}</td>
                <td>{step.owner}</td>
                <td>{step.deadline}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </section>

      <section className="assumptions">
        <h3>Critical Assumptions</h3>
        {strategicBrief.criticalAssumptions.map((ass, idx) => (
          <div key={idx} className="assumption-card">
            <h4>{ass.assumption}</h4>
            <p><strong>Risk if wrong:</strong> {ass.riskIfWrong}</p>
            <p><strong>Validate by:</strong> {ass.validationMethod}</p>
          </div>
        ))}
      </section>
    </div>
  );
}

// App entry point
export function MarketEvaluationApp({ jobId }: { jobId: string }) {
  return (
    <JuggernautProvider 
      jobId={jobId}
      apiKey={process.env.REACT_APP_JUGGERNAUT_KEY!}
    >
      <EvaluationContent />
    </JuggernautProvider>
  );
}

Example 2: Bulk Lead Scoring with Iterative Processing

Scenario: Process 50 sales leads individually, score them, aggregate results.

Process Definition

{
  "name": "Lead Scoring Engine",
  "description": "Processes lead lists with AI scoring and prioritization",
  "defaultModel": "openai-gpt-4",
  "inputs": [
    {
      "name": "leads",
      "type": "array",
      "description": "Array of lead objects with contact info and notes",
      "required": true
    },
    {
      "name": "scoringCriteria",
      "type": "string",
      "description": "Specific factors to prioritize (e.g., 'budget authority, timeline')",
      "required": true
    }
  ],
  "pipelines": [
    {
      "name": "Score Leads",
      "description": "Iterative individual lead analysis",
      "type": "sync",
      "steps": [
        {
          "name": "Score Individual Lead",
          "outputName": "append:scoredLeads",
          "type": "Iterative",
          "iterations": "@leads.length",
          "taskType": "LLM",
          "messages": [
            {
              "type": "system",
              "content": "You are a sales analyst. Score leads 0-100 based on provided criteria."
            },
            {
              "type": "user",
              "content": "Score this lead ({{SYSTEM:STEPINDEX}} of {{leads.length}}): {{STEPLOOP(leads)}}. Criteria: {{scoringCriteria}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Individual lead scoring result",
              "properties": {
                "leadId": {
                  "type": "string",
                  "description": "Identifier from input lead"
                },
                "score": {
                  "type": "number",
                  "description": "Quality score 0-100"
                },
                "tier": {
                  "type": "string",
                  "description": "Priority bucket: hot, warm, cold"
                },
                "rationale": {
                  "type": "string",
                  "description": "Brief explanation for score"
                },
                "recommendedAction": {
                  "type": "string",
                  "description": "Next step: immediate_call, nurture, or disqualify"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Aggregate and Prioritize",
      "description": "Compile final report",
      "type": "sync",
      "steps": [
        {
          "name": "Generate Summary Report",
          "outputName": "scoringReport",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Analyze these {{scoredLeads.length}} scored leads and provide summary: {{scoredLeads}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Aggregate scoring report",
              "properties": {
                "totalLeads": {
                  "type": "number",
                  "description": "Count processed"
                },
                "averageScore": {
                  "type": "number",
                  "description": "Mean score"
                },
                "distribution": {
                  "type": "object",
                  "description": "Count by tier",
                  "properties": {
                    "hot": {
                      "type": "number",
                      "description": "Count of hot leads"
                    },
                    "warm": {
                      "type": "number",
                      "description": "Count of warm leads"
                    },
                    "cold": {
                      "type": "number",
                      "description": "Count of cold leads"
                    }
                  }
                },
                "topPriority": {
                  "type": "array",
                  "description": "Top 5 leads requiring immediate action",
                  "items": {
                    "type": "object",
                    "description": "Priority lead summary",
                    "properties": {
                      "leadId": {
                        "type": "string",
                        "description": "Lead identifier"
                      },
                      "score": {
                        "type": "number",
                        "description": "Quality score"
                      },
                      "contactStrategy": {
                        "type": "string",
                        "description": "Recommended approach"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

Example 3: Conditional Routing for Content Processing

Scenario: Route documents to different processing pipelines based on detected type.

Process Definition

{
  "name": "Smart Document Processor",
  "description": "Classifies and routes documents to specialized extraction pipelines",
  "defaultModel": "google-gemini-2.5-flash",
  "inputs": [
    {
      "name": "document",
      "type": "string",
      "description": "Document text content or OCR result",
      "required": true
    },
    {
      "name": "source",
      "type": "string",
      "description": "Origin: email, upload, scan",
      "required": true
    }
  ],
  "pipelines": [
    {
      "name": "Classification",
      "description": "Determine document type",
      "type": "sync",
      "steps": [
        {
          "name": "Classify Document",
          "outputName": "classification",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Classify this document: {{document}}. Source: {{source}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Classification result",
              "properties": {
                "documentType": {
                  "type": "string",
                  "description": "Detected type: invoice, contract, report, correspondence, other"
                },
                "confidence": {
                  "type": "number",
                  "description": "Classification confidence 0-1"
                },
                "priority": {
                  "type": "string",
                  "description": "Urgency: critical, high, normal, low"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Router",
      "description": "Route to specialized pipeline",
      "type": "conditional",
      "conditions": {
        "$classification.documentType == invoice": 2,
        "$classification.documentType == contract": 3,
        "$classification.documentType == report": 4,
        "default": 5
      }
    },
    {
      "name": "Invoice Processing",
      "description": "Extract invoice data",
      "type": "sync",
      "steps": [
        {
          "name": "Extract Invoice Data",
          "outputName": "extractedData",
          "type": "Standard",
          "taskType": "LLM",
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Invoice fields",
              "properties": {
                "vendor": {
                  "type": "string",
                  "description": "Vendor name"
                },
                "amount": {
                  "type": "number",
                  "description": "Total amount"
                },
                "dueDate": {
                  "type": "string",
                  "description": "ISO date"
                },
                "lineItems": {
                  "type": "array",
                  "description": "Itemized charges",
                  "items": {
                    "type": "object",
                    "description": "Line item",
                    "properties": {
                      "description": {
                        "type": "string",
                        "description": "Item description"
                      },
                      "amount": {
                        "type": "number",
                        "description": "Line amount"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Contract Processing",
      "description": "Extract contract terms",
      "type": "sync",
      "steps": [
        {
          "name": "Extract Contract Terms",
          "outputName": "extractedData",
          "type": "Standard",
          "taskType": "LLM",
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Contract analysis",
              "properties": {
                "parties": {
                  "type": "array",
                  "description": "Contracting entities",
                  "items": {
                    "type": "string",
                    "description": "Party name"
                  }
                },
                "effectiveDate": {
                  "type": "string",
                  "description": "Contract start"
                },
                "value": {
                  "type": "number",
                  "description": "Contract value"
                },
                "keyTerms": {
                  "type": "array",
                  "description": "Important clauses",
                  "items": {
                    "type": "object",
                    "description": "Contract term",
                    "properties": {
                      "clause": {
                        "type": "string",
                        "description": "Clause name"
                      },
                      "summary": {
                        "type": "string",
                        "description": "Plain English explanation"
                      },
                      "risk": {
                        "type": "string",
                        "description": "Risk level: low, medium, high"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Report Processing",
      "description": "Summarize report content",
      "type": "sync",
      "steps": [
        {
          "name": "Summarize Report",
          "outputName": "extractedData",
          "type": "Standard",
          "taskType": "LLM",
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Report summary",
              "properties": {
                "title": {
                  "type": "string",
                  "description": "Report title"
                },
                "executiveSummary": {
                  "type": "string",
                  "description": "Key findings"
                },
                "actionItems": {
                  "type": "array",
                  "description": "Required actions",
                  "items": {
                    "type": "string",
                    "description": "Action item"
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Generic Processing",
      "description": "Standard extraction for unknown types",
      "type": "sync",
      "steps": [
        {
          "name": "Generic Extraction",
          "outputName": "extractedData",
          "type": "Standard",
          "taskType": "LLM",
          "messages": [
            {
              "type": "user",
              "content": "Extract key information from this document: {{document}}"
            }
          ],
          "options": {
            "outputFormat": "json",
            "outputSettings": {
              "type": "object",
              "description": "Generic extraction",
              "properties": {
                "summary": {
                  "type": "string",
                  "description": "Brief summary"
                },
                "entities": {
                  "type": "array",
                  "description": "Named entities found",
                  "items": {
                    "type": "string",
                    "description": "Entity name"
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

Best Practices Demonstrated

  1. Schema Discipline: Every example includes complete description fields for all properties
  2. State Modifiers: Example 2 shows append: usage for accumulating iterative results
  3. Conditional Logic: Example 3 demonstrates index-based routing with default fallbacks
  4. Type Safety: TypeScript interfaces match JSON schemas exactly
  5. Cost Awareness: Examples use appropriate model tiers (flash for classification, pro for analysis)