If Statement Task¶
Overview¶
The If Statement Task adds decision-making logic to workflows. It evaluates conditions and routes the workflow down different paths based on whether conditions are true or false.
When to use this task:
- Check if a field has a value before proceeding
- Route workflows based on contact status or tags
- Validate data before creating records
- Handle different scenarios (new vs existing customers)
- Skip tasks when conditions aren't met
- Create complex business logic flows
Key Features:
- Multiple condition types (equals, contains, greater than, etc.)
- AND/OR logic for complex conditions
- Text, number, and date comparisons
- Empty/not empty checks
- Pattern matching and regex support
- True/False path routing
The task has two output ports, and each child task is wired to one of them. A task connected to the wrong port simply never runs:
flowchart LR
A[Incoming data] --> B{Condition}
B -->|true| C[Tasks on the true port]
B -->|false| D[Tasks on the false port]
Quick Start¶
Builder fields¶
The Field column is the label as it appears in the task builder; Key is the name the value is stored under and referenced by.
| Field | Key | Type | Default | Notes |
|---|---|---|---|---|
| Conditions | _conditions |
condition-builder | – |
- Add If Task to workflow
- Select condition type (e.g., "Equals")
- Enter first value:
{{task_12345_status}} - Enter second value:
Customer - Add tasks after If task
- Configure which tasks run when True vs False
Simple Example:
Condition: {{task_15001_contact_found}} equals true
If True: Continue to welcome email
If False: Skip welcome email
Condition Types¶
Equals¶
Tests if two values are exactly the same.
Configuration:
Case Sensitivity:
- Default: Case-insensitive (
john@example.com=JOHN@EXAMPLE.COM) - Enable "Case Sensitive" for exact matching
Use cases:
- Check contact status
- Verify specific email domains
- Match exact values
Not Equals¶
Tests if two values are different.
Configuration:
Use cases:
- Exclude specific values
- Filter out unwanted data
- Negative matching
Contains¶
Tests if Value 1 includes Value 2 anywhere within it.
Configuration:
Example matches:
Tags: "VIP, Customer, 2024" → Contains "VIP" ✓
Tags: "Very Important Person" → Contains "VIP" ✓
Tags: "Customer, Lead" → Contains "VIP" ✗
Use cases:
- Check if tag exists in tag list
- Search for keywords in text
- Partial string matching
Does Not Contain¶
Tests if Value 1 does NOT include Value 2.
Configuration:
Use cases:
- Exclude personal email domains
- Filter out specific keywords
- Negative pattern matching
Greater Than / Less Than¶
Compares numeric values.
Configuration:
Number formats supported:
Date comparisons:
Use cases:
- Lead scoring thresholds
- Age verification
- Date range filtering
- Quantity checks
Starts With / Ends With¶
Tests if text begins or ends with specific characters.
Starts With:
Ends With:
Use cases:
- Country code validation
- Email domain filtering
- Prefix/suffix matching
Is Empty / Is Not Empty¶
Checks if a field has any value.
Is Empty:
Returns True if:
- Field is null
- Field is empty string ""
- Field is whitespace only
Is Not Empty:
Use cases:
- Data validation
- Required field checking
- Skip tasks if data missing
Regex Match¶
Tests if value matches a regular expression pattern.
Configuration:
Common patterns:
Email validation:
Phone (SA format):
Postal code:
URL:
Use cases:
- Advanced validation
- Pattern extraction
- Complex string matching
Multiple Conditions¶
Combine conditions with AND/OR logic.
AND Logic (All Must Be True)¶
Configuration:
Condition 1: {{task_15001_status}} Equals "Lead"
AND
Condition 2: {{task_15001_custom_lead_score}} Greater Than 50
AND
Condition 3: {{task_15001_tags}} Contains "Active"
Result: All three conditions must be true to proceed.
Use case: Qualify hot leads
OR Logic (Any Can Be True)¶
Configuration:
Condition 1: {{task_15001_status}} Equals "Customer"
OR
Condition 2: {{task_15001_tags}} Contains "VIP"
OR
Condition 3: {{task_15001_custom_lifetime_value}} Greater Than 10000
Result: If ANY condition is true, proceed.
Use case: Identify high-value contacts
Mixed AND/OR Logic¶
Configuration:
Example:
Meaning: Hot leads OR any customer.
True/False Path Routing¶
Path Configuration¶
After If Task, subsequent tasks can be configured to run conditionally:
Execution Flow:
1. If Task
2. Email Task - Set to run only if "True"
3. SMS Task - Set to run only if "False"
4. Workflow Note - Set to run "Always" (both paths)
Task Settings:
- Run When: True / False / Always
- Stop if False: Stop workflow vs Continue
Example Flow¶
1. Website Form
2. Match to Client
3. If Task: Check {{task_15_contact_found}} = true
If TRUE:
4a. Edit Client - Update with new data
5a. Email - "Thanks for getting in touch again"
If FALSE:
4b. New Client - Create contact
5b. Email - "Welcome to our system"
ALWAYS (both paths):
6. Email - Notify sales team
Stop Workflow on False¶
Configuration:
Result:
- True: Continue workflow
- False: Stop immediately, don't run subsequent tasks
Use case: Data validation gates
Outputs¶
| Field | Type | Example | Notes |
|---|---|---|---|
run |
boolean | true |
The decision. true means the condition passed; false means it did not. |
run_text |
string | Condition met. |
Which comparison was evaluated and how it resolved. |
That is the whole output. The task carries no result, condition_met, value_1 or value_2
field — the branch itself is the output.
You rarely read this task's output
Children are routed by which port they are wired to, so the usual pattern is to wire tasks to the
true and false ports rather than to test run downstream. Read run only when a later task needs
to know which way an earlier branch went.
Real-World Examples¶
Treat new and returning customers differently¶
Form Submission
└─ Match to Client contact_email from the form
└─ If Statement run is true
├─ true ─ Email "Welcome back"
└─ false ─ New Client create the record
Escalate only poor reviews¶
Google Review Received
└─ If Statement {{task_63001_star_rating}} is 1, 2 or 3
├─ true ─ Email alert a person
└─ false ─ Reply to Google Review post a thank-you
Skip contacts who opted out¶
Schedule
└─ Contact get the contact
└─ If Statement {{task_28001_contact_sms_unsubscribe}} is false
└─ SMS send the message
Best Practices¶
Condition Design¶
- Be specific -
Equals "Active"notContains "Act" - Handle empty values - Always check
Is Not Emptyfirst - Use appropriate operators - Numeric: Greater Than, Text: Contains
- Test edge cases - What if field is null? Empty? Zero?
Logic Structure¶
- Validate early - Put validation If tasks at start of workflow
- Fail fast - Stop workflow if critical conditions fail
- Avoid deep nesting - Max 2-3 levels of If tasks
- Document complex logic - Use task notes to explain
Performance¶
- Simple conditions first - Fast checks before slow ones
- Minimize If tasks - Combine conditions with AND/OR
- Cache results - Store If results in variables if reused
- Avoid redundant checks - Don't check same condition twice
Maintainability¶
- Clear naming - "Check if VIP customer" not "If Task 1"
- Consistent values - Use same casing for comparisons
- Comment complex conditions - Explain business logic
- Group related conditions - Keep related If tasks together
Troubleshooting¶
Condition Always False¶
Check:
- Value format -
"100"(text) ≠100(number) - Extra spaces -
"Customer "≠"Customer" - Case sensitivity - Enable case-insensitive if needed
- Empty values - Add
Is Not Emptycheck first
Debug: View execution history to see actual values:
Wrong Path Taken¶
Common causes:
- OR vs AND confusion - Check logic operator
- Negation errors - "Not Equals" vs "Equals"
- Type mismatch - String "100" vs Number 100
- Null values - Null fails most comparisons
Test approach:
Add Variable task before If task:
- Store value being tested
- View in execution history
- Verify format and content
Workflow Doesn't Stop¶
Check:
- "Stop Workflow if False" setting enabled?
- Subsequent tasks set to "Always run"?
- Is there a Loop task that continues despite failure?
Number Comparisons Not Working¶
Ensure:
✗ Value: "100" (text with quotes)
✓ Value: 100 (numeric)
✗ Value: R1,234.56 (with currency symbol)
✓ Value: 1234.56 (numeric only)
Solution: Use Text Formatter task to clean numbers first.
Frequently Asked Questions¶
Can I nest If tasks?¶
Yes, but keep it simple:
How do I check multiple possible values?¶
Use OR conditions:
Or use Contains with delimited list:
Can I compare two dynamic values?¶
Yes:
What if I need more than True/False paths?¶
Use multiple If tasks in sequence:
1. If: Status = "Lead" → Path A
2. Else If: Status = "Customer" → Path B
3. Else If: Status = "Partner" → Path C
4. Else: Default Path D
How do I test for null vs empty string?¶
Both return True for "Is Empty":
Can I use wildcards?¶
Not in standard conditions. Use Regex Match:
Should I use If task or Conditional trigger filtering?¶
Use trigger filtering when:
- Preventing workflow from starting
- Filtering at source (more efficient)
Use If task when:
- Logic depends on multiple tasks' results
- Need different actions for True/False
- Validating data mid-workflow
Related Tasks¶
- Loop Task - Iterate with conditional logic
- Variable Task - Store condition results
- Code Task - Complex custom logic
- Match to Client - Conditional contact matching
- Webhook Out - Conditional API calls