Advanced Workflow Patterns: Branching, Loops, and Error Handling
4 / 5Once you have built a simple linear workflow, you will quickly encounter situations that require more sophisticated logic. This lesson covers the patterns that make workflows genuinely powerful.
Branching: Handling Multiple Scenarios
Most real-world workflows need to handle different cases differently. This requires branching.
Example: Content type routing A content submission form receives articles, social posts, and video scripts — each needing a different review process and AI prompt.
In Zapier: use "Paths" — multiple branches that run based on conditions In Make: use "Router" — split flow into parallel branches with conditions
- Structuring good branches:
- Make each branch mutually exclusive (no overlap in conditions)
- Have a default/fallback branch for unexpected values
- Test each branch independently before testing the whole workflow
AI-Driven Branching
A powerful pattern: let the AI decide which branch to take.
Instead of rule-based branching (if category = X), ask the AI to classify the input and then branch based on its output.
AI prompt: "Classify this customer message as one of: REFUND_REQUEST, TECHNICAL_ISSUE, GENERAL_INQUIRY, COMPLAINT, POSITIVE_FEEDBACK. Return only the category name."
Then branch based on the classification. This is more flexible than trying to write rules that cover every case.
Loops: Processing Multiple Items
Loops are needed when you have multiple items to process — a list of emails, a set of rows in a spreadsheet, a collection of articles.
- Make: Has native iteration (loops) through lists
- Zapier: Handles this with "Looping by Zapier" or by designing multi-step Zaps
- n8n: Has powerful loop nodes
- Common loop patterns:
- Process each row in a Google Sheet
- Analyse each article in an RSS feed
- Send a personalised message to each item in a list
Watch for: Loop workflows can run many times and consume many AI tokens. Always test with a small sample first.
Error Handling: Making Workflows Resilient
Workflows fail. The API call times out. The AI returns an unexpected format. Without error handling, a failed step silently stops the workflow.
Basic error handling patterns:
Timeout retries: Configure your automation tool to retry failed steps 2-3 times before giving up.
Error notifications: Add a branch that triggers if any step fails, sending you a notification with the error details.
Data validation: Before passing AI output to the next step, validate it is in the expected format.
Fallback paths: If the AI step fails, route the item to a human for manual processing.
The Idempotency Principle
Build workflows so they can run multiple times on the same data without creating duplicate outputs.
Check if a record already exists before creating it. Track processed IDs. Use upsert operations rather than insert.
This matters because workflows often re-run due to retries, and you do not want to send a customer three auto-reply emails because the API timed out twice.
0/5 complete