Condition Node
The Condition node enables intelligent branching in your workflows, with AI assistance to help write complex conditions in plain English.
Overview
Create decision points that route data based on:
- Simple comparisons
- Complex logic expressions
- Pattern matching
- AI-evaluated conditions
- Multiple output branches
✨ AI Condition Wizard
The Condition node features an AI-powered wizard that converts natural language to conditions:
Using the AI Wizard
- Click the sparkles (✨) button in the condition field
- Describe your condition in plain English:
- "Check if the order total is over 100"
- "Customer is premium and has made 5+ purchases"
- "Email contains urgent or critical"
- AI generates the condition automatically
- Review and apply the generated expression
AI Wizard Examples
Natural Language → Generated Condition
"Order is high value" → input.orderTotal > 1000
"Customer needs attention" → input.satisfaction < 5 || input.complaints > 2
"Text mentions refund or return" → /refund|return/i.test(input.message)
"Date is in the past" → new Date(input.date) < new Date()
Configuration
Condition Types
JavaScript Expression (Default)
Write or generate JavaScript conditions:
// Simple comparison
input.value > 100
// Multiple conditions
input.status === 'active' && input.tier === 'premium'
// Array checks
input.items.length > 0 && input.items.some(item => item.urgent)
// Pattern matching
input.email.includes('@company.com')
AI Evaluation
Let AI evaluate complex conditions:
✨ "Customer sentiment is negative based on their message"
✨ "This looks like a spam email"
✨ "The data quality is poor"
Output Branches
Condition nodes have two or more output paths:
- True Branch (green) - Condition is met
- False Branch (red) - Condition is not met
- Additional Branches (optional) - For multi-way decisions
Basic Conditions
Comparisons
// Numeric
input.amount > 1000
input.count >= 10
input.score < 50
input.value <= 100
input.quantity === 5
input.total !== 0
// String
input.status === 'active'
input.category !== 'archived'
input.name.startsWith('John')
input.email.endsWith('@gmail.com')
input.message.includes('urgent')
Boolean Logic
// AND conditions
input.age >= 18 && input.hasConsent === true
// OR conditions
input.priority === 'high' || input.deadline < Date.now()
// NOT conditions
!input.isProcessed
!(input.status === 'deleted')
// Complex combinations
(input.tier === 'premium' || input.purchases > 10) && !input.suspended
Advanced Conditions
Array Operations
// Check if array exists and has items
input.items && input.items.length > 0
// Find specific items
input.products.some(p => p.price > 100)
input.users.every(u => u.verified)
input.tags.includes('featured')
// Array filtering
input.orders.filter(o => o.status === 'pending').length > 5
Object Checks
// Check if property exists
'email' in input
input.hasOwnProperty('userId')
input.user?.address?.city
// Nested properties (safe)
input?.customer?.subscription?.active === true
// Object keys
Object.keys(input).length > 0
Object.values(input.stats).some(v => v > 100)
Regular Expressions
// Pattern matching
/^[A-Z]{3}-\d{4}$/.test(input.code) // ABC-1234
/urgent|critical|emergency/i.test(input.subject)
input.phone.match(/^\+?[1-9]\d{1,14}$/)
// Email validation
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input.email)
Date Comparisons
// Date checks
new Date(input.date) > new Date() // Future date
Date.now() - new Date(input.created) > 86400000 // Older than 24 hours
// Business hours
new Date().getHours() >= 9 && new Date().getHours() < 17
// Day of week (0 = Sunday)
new Date().getDay() >= 1 && new Date().getDay() <= 5 // Weekday
Multi-Branch Conditions
Switch-like Behavior
Create multiple branches using else-if chains:
// Branch 1: High Priority
input.priority === 'critical' || input.value > 10000
// Branch 2: Medium Priority
input.priority === 'high' || input.value > 1000
// Branch 3: Low Priority (else)
true
Category Routing
// Branch by department
input.department === 'sales' // → Sales flow
input.department === 'support' // → Support flow
input.department === 'technical' // → Technical flow
// Default branch for others
AI-Powered Conditions
Sentiment Analysis
Use the AI wizard for intelligent evaluation:
✨ "Customer message has negative sentiment"
✨ "Feedback is positive and actionable"
✨ "Review contains complaint about pricing"
Content Classification
✨ "Email is likely spam"
✨ "Message requires urgent response"
✨ "Document contains sensitive information"
Data Quality
✨ "Address data looks incomplete"
✨ "Phone number format is invalid for US"
✨ "Dataset has too many missing values"
Common Patterns
Null/Undefined Checks
// Check if exists
input.data !== null && input.data !== undefined
input.value != null // Checks both null and undefined
// Check if empty
!input.message || input.message.trim() === ''
// Safe navigation
input?.user?.email || 'no-email@example.com'
Type Checking
// Check types
typeof input.value === 'number'
typeof input.name === 'string'
Array.isArray(input.items)
input.date instanceof Date
// Numeric validation
!isNaN(parseFloat(input.amount))
Number.isInteger(input.count)
Business Rules
// Discount eligibility
input.customerTier === 'gold' || input.orderTotal > 500
// Approval required
input.amount > 1000 && input.department === 'finance'
// Risk assessment
input.failedAttempts > 3 || input.location !== input.usualLocation
Best Practices
1. Use AI Wizard First
Start with natural language, then refine:
✨ "Order needs manager approval"
// Generated: input.total > 5000 || input.items.some(i => i.restricted)
2. Handle Edge Cases
// Check for existence first
input.users && input.users.length > 0 && input.users[0].active
// Use optional chaining
input?.order?.items?.length > 0
// Provide defaults
(input.limit || 10) > 5
3. Keep Conditions Simple
// ❌ Too complex
(input.a > 10 && input.b < 5) || (input.c === 'x' && input.d !== null) && input.e.length > 0
// ✅ Better: Split into multiple conditions or use AI
✨ "Complex approval logic for orders"
4. Test with Various Inputs
Test your conditions with:
- Empty/null values
- Edge cases (0, negative numbers, empty strings)
- Unexpected types
- Missing properties
Debugging Conditions
Add Logging
Use a Code node before the Condition to debug:
console.log('Checking condition with:', input);
console.log('Value type:', typeof input.value);
console.log('Evaluation result:', input.value > 100);
return input;
Common Issues
"Cannot read property of undefined"
// Problem
input.user.email === 'test@example.com'
// Solution
input.user && input.user.email === 'test@example.com'
// Or
input?.user?.email === 'test@example.com'
"Unexpected token"
// Problem
input.status = 'active' // Assignment instead of comparison
// Solution
input.status === 'active' // Comparison
Examples
E-commerce Order Routing
// High-value orders
input.orderTotal > 1000 || input.customerTier === 'vip'
// Rush processing
input.shipping === 'express' || input.priority === 'urgent'
// Fraud check needed
input.isFirstOrder && input.orderTotal > 500
Support Ticket Priority
// Critical - immediate attention
input.severity === 'critical' ||
input.subject.toLowerCase().includes('security') ||
input.affectedUsers > 100
// High - quick response
input.severity === 'high' ||
input.customerTier === 'enterprise' ||
input.responseTime < 4
Data Validation
// Valid email and phone
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input.email) &&
/^\+?[1-9]\d{1,14}$/.test(input.phone)
// Complete address
input.address &&
input.address.street &&
input.address.city &&
input.address.postalCode
Integration with Other Nodes
After Agent Node
Use AI output for intelligent routing:
// Agent classifies sentiment
input.sentiment === 'negative' // Route to escalation
// Agent extracts priority
input.extractedPriority > 7 // High priority flow
Before Loop Node
Decide whether to process array:
input.items && input.items.length > 0 && !input.skipProcessing
With Plugin Nodes
Route based on plugin results:
input.apiResponse.success && input.apiResponse.data.approved
Tips
- Start with AI: Describe what you want, refine the generated code
- Test edge cases: Always handle null/undefined
- Use console.log: Debug complex conditions
- Chain conditions: Break complex logic into multiple nodes
- Document intent: Add comments for complex conditions
Related Topics
- Code Node - Write complex logic
- Agent Node - AI-powered evaluation
- Loop Node - Process arrays after filtering
- Template Variables - Dynamic conditions