%%{init:{"theme":"base","themeVariables":{"primaryColor":"#eef2ff","primaryTextColor":"#1e1b4b","primaryBorderColor":"#6366f1","lineColor":"#6366f1","clusterBkg":"#f8f9ff","clusterBorder":"#6366f1","titleColor":"#1e1b4b","edgeLabelBackground":"#f6f4ef","fontFamily":"system-ui,sans-serif","fontSize":"13px"}}}%%
flowchart TD
Q1{{"Q1: Probabilistic output needed?"}}:::decision -->|No| R1["Use Rules"]:::fallback
Q1 -->|Yes| Q2{{"Q2: Training data available?"}}:::decision
Q2 -->|No| R2["Use Rules"]:::fallback
Q2 -->|Yes| Q3{{"Q3: Output can be validated?"}}:::decision
Q3 -->|No| R3["Human Review"]:::fallback
Q3 -->|Yes| Q4{{"Q4: Value justifies API cost?"}}:::decision
Q4 -->|No| R4["Use Rules"]:::fallback
Q4 -->|Yes| R5["Use AI"]:::success
classDef trigger fill:#dcfce7,stroke:#16a34a,color:#14532d,font-weight:600
classDef process fill:#eef2ff,stroke:#6366f1,color:#1e1b4b
classDef decision fill:#fef9c3,stroke:#ca8a04,color:#78350f,font-weight:600
classDef success fill:#d1fae5,stroke:#059669,color:#064e3b,font-weight:700
classDef fallback fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
Chapter 1.1 AI in Business Operations
Learning Objectives
After completing this chapter, you will be able to:
- Identify the four AI capability categories (classification, extraction, enrichment, generation) and match each to the correct type of workflow problem.
- Apply the AI suitability decision framework to route any incoming workflow problem to rule-only processing, AI-assisted processing, or human review.
- Explain why AI adds cost, latency, and non-determinism to a workflow, and describe when those costs are justified versus avoidable.
- Design a suitability routing layer that evaluates each submission and assigns it to the correct processing path before any API call is made.
- Distinguish between a classification output schema and an extraction output schema, and explain how each is consumed differently by downstream workflow nodes.
Introduction
In Chapter 1.0, you established the conceptual architecture for AI in automation: a deterministic rule layer that executes first, an AI enrichment layer that operates within a bounded contribution envelope, a combination layer that merges the two, and a human override layer that retains final authority. You built a simple recruiting workflow that added an AI classification step to an existing API automation.
That chapter did not answer one question: how do you know when AI belongs in a workflow at all?
The answer is not obvious, and the cultural pressure to get it wrong is real. AI has become associated with sophistication, which creates a natural pressure to add it wherever possible to make an automation feel smarter, to justify the engineering investment, or simply because the capability exists. This is a mistake with measurable cost. AI adds latency, billing overhead, and non-determinism to every workflow it touches. An AI call that could have been a rule is not just unnecessary it is a latency tax, a billing line, and a potential failure point. The automation engineer who knows precisely when AI is warranted and who uses rules when rules are sufficient produces better systems than the one who adds AI to every pipeline because it is available.
This chapter teaches you how to make that judgment call. The central question is whether a problem requires semantic interpretation of natural language, or whether it can be solved with structured field comparisons. If the data you need to make a decision exists in typed, structured fields numbers, dates, booleans, enums use rules. If the data exists in free-form text and the decision requires reading its meaning, use AI.
Around that central distinction, the chapter builds four AI capability categories classification, extraction, enrichment, and generation and a practical decision framework that routes any workflow problem to the correct processing path. The chapter closes with an implementation: a suitability routing layer that evaluates each incoming submission and assigns it to rule-only processing, AI-assisted processing, or human review before a single API call is made.
The commercial real estate lead scoring system in Chapter 2.5 uses AI for exactly one thing: interpreting a free-text inquiry message to extract an intent signal. Every other routing and scoring decision in that system uses deterministic logic. The targeted, bounded application of AI is not a limitation it is the correct allocation of the tool to the problems it actually solves.
1.1.1 AI as Classification
Classification
When a workflow needs to route incoming records by message type support ticket, sales inquiry, complaint, general question the routing decision depends on what the text means, not which field value it carries. That is the classification problem: a task that takes free-form text as input and assigns it to one of a predefined set of categories, returning a label, a confidence score, and the signals that drove the decision.
The pattern applies when three conditions hold. The input data is in a free-form text field that keyword matching cannot reliably categorize because the same topic appears in different words, phrasings, and contexts. The target categories are stable and finite, expressible as a closed enum. And the downstream workflow needs a typed category value to route or process the record. The use cases share this shape: routing support tickets by issue type, assigning customer feedback to a sentiment bucket, flagging content as compliant or non-compliant, identifying the inquiry type of a sales lead. In each case, the routing decision depends on what the text means and that is precisely what rules cannot determine from structured fields alone.
Classification Output Schema
The output schema for a classification task is compact: {category, confidence, signals}. The category field is an enum a closed set of permitted string values. The confidence field is a float between 0.0 and 1.0. The signals field is an array of short strings identifying the evidence. This schema is validated by the Parse Response Code node before any downstream logic consumes it.
From an architectural standpoint, classification sits at the input layer of the workflow it runs on the raw submission, before downstream processing, and its output determines the processing path. The output of a classification node is a type converter: free-form text → enum value + confidence + signals. Downstream nodes treat category as a typed field without knowing or caring that an LLM produced it. The classification is consumed once and does not need to be recomputed for the same record.
Classification into too many categories produces lower confidence per category and harder downstream routing logic. Start with the minimum viable set that drives distinct workflow behavior if three category values all result in the same downstream action, they are one category.
LLMs can produce values outside the specified enum returning "EMERGENCY" in uppercase when the prompt specifies "emergency", or inventing a new category not in the schema. The Parse Response node must validate the category value against the permitted set and set ai_result_valid = false if the value does not match.
1.1.2 AI as Extraction
Extraction
Where classification assigns a label to a piece of text, extraction pulls specific structured data points out of it identifying and isolating named entities, facts, dates, amounts, or other specific values embedded in prose.
The scenario that calls for extraction is a form that captures the right data in the wrong format: a project brief where the client mentioned a budget figure in a notes field, a cover letter where the candidate named their current employer in free text because no dedicated field existed. The data is there it is just not in a typed slot where downstream logic can act on it.
Extraction belongs when structured data points exist in a free-form field but are not captured in dedicated fields, when the extracted values need to be stored in a structured system, and when natural variation in human writing defeats regular expression matching. Pulling a company name and role title from a cover letter, extracting a quoted budget range from a project brief, identifying specific product names from a support ticket these are extraction problems because the data exists, but it must be located and isolated before it becomes usable.
Extraction Output Schema
The output schema for an extraction task is a set of optional fields: {company_name, budget_range, timeline, product_mentioned}. Each field may be null if the information was not present in the text. The validation step must handle null values gracefully: a missing field should set ai_result_valid = false only if that field is a required extraction target. For optional fields, null is a valid result that means “not in the text,” not a failure.
Architecturally, extraction sits at the data enrichment point of the workflow after initial validation and before scoring or routing. The extracted fields are written to the record and become available to all downstream steps as typed data. In the Part II CRM platform, the signals-detected array in the lead scoring prompt is a lightweight form of extraction: the model identifies and names the specific signals that informed its scoring, which become part of the audit record and give the client a human-readable explanation of the AI’s decision.
Null extraction results are expected, valid outputs, not AI failures. A null means the information was not in the text. Reserve ai_result_valid = false for actual failures: API errors, parse failures, and malformed responses.
1.1.3 AI as Enrichment
Enrichment
Enrichment adds a new structured dimension to an existing record one that was not present in the original submission and cannot be derived from the fields that were. It differs from extraction in that it produces a computed value, not an identified value. Where extraction asks “what is already in this text?”, enrichment asks “what does this text tell us about a quality that wasn’t directly stated?”
The moment that calls for enrichment is when scoring or routing logic needs a dimension the form didn’t collect not a field someone forgot to add, but a quality that cannot be measured directly: how serious is this person about the project? How well does this application fit the role? How sophisticated is this client’s understanding of what they are asking for? Those questions require reading what the text expresses, not computing from what the form returned.
Enrichment belongs when the record needs a scored dimension that encodes that judgment, when the judgment requires semantic reading rather than field comparison, and when the enriched value feeds downstream scoring, routing, or prioritization. Assigning a communication sophistication score to a professional services inquiry, generating a fit assessment between a job application and a role description, computing a content quality score for a marketing submission all produce a new dimension the rule layer cannot derive.
The output of an enrichment task is a typed score or assessment value:
{
"intent_level": 7,
"confidence": 0.83,
"signals": ["urgent deadline", "specific budget mentioned", "prior vendor experience"]
}The value is not a fact extracted from the text it is the AI’s judgment about a quality the text expresses. This makes confidence gating especially important for enrichment: a high-confidence enrichment with intent_level: 7 and confidence: 0.88 is a meaningfully different signal from the same intent_level with confidence: 0.51. The combination formula’s confidence multiplier is designed specifically for this asymmetry.
The confidence field is not supplementary metadata it is the first routing signal the downstream architecture consumes. At 1.5.2 Confidence Bands and Thresholds, confidence bands determine whether the AI contribution is applied at full weight, partial weight, or not at all. The combination formula at 1.4.5 AI-Assisted Routing implements this as a multiplier: the same intent_level: 7 carries different weight depending on whether confidence is 0.88 or 0.51. Every enrichment output that includes a valid confidence field participates in both decisions; one without it cannot.
Confidence gating is especially important for enrichment scores.
This is the pattern at the center of Chapter 2.5. The AI layer in the Part II lead scoring system enriches the lead record with an intent score that encodes the model’s assessment of urgency, specificity, seriousness, and fit a new data dimension the rule layer cannot produce. That score is bounded within a defined contribution envelope and combined with the rule score to produce the final priority tier.
Enrichment scores are not authoritative. A lead with an AI intent score of 8 but a rule score of 2 is not equivalent to a lead with both scores high. The combination formula exists precisely to prevent any single layer from dominating the result.
Do not remove the enrichment contribution cap. The min(4, ai_score × multiplier) formula is not optional it is the engineering constraint that keeps the enrichment layer in its advisory role. Every enrichment output must also include a signals array. Without signals, the enrichment score is unauditable and undebuggable.
1.1.4 AI as Generation
Generation
Generation runs in the opposite direction from the other three patterns: where classification, extraction, and enrichment consume text and produce structured data, generation consumes structured data and produces text.
The question that calls for generation is not “should I use AI?” but “can a template do this?” If the communication must vary meaningfully from record to record drawing on the specific details of a CRM record to write a genuinely personalized follow-up, or capturing the actual judgment calls in a support thread rather than a mechanical summary template substitution produces results that feel generic because they are. Generation belongs when the output is a human-readable communication whose quality depends on context-sensitive language that substitution cannot produce, and when the generated content goes to a human reviewer before it goes anywhere else. The use cases: drafting a personalized follow-up email for a sales lead from their CRM record, summarizing a support ticket thread for the escalation team, producing a first-draft property description from structured property attributes, generating a meeting recap from a structured notes schema.
Generation is not used in Part I or Part II as a primary workflow capability those phases focus on classification, extraction, and enrichment because those patterns produce structured outputs that downstream nodes can consume programmatically. Generation produces unstructured text that requires a human review stage before use. But generation is the most commercially visible AI capability in client conversations, and understanding its proper place and its governance requirements matters as much as understanding the other patterns.
The correct architectural position for generation is: complete all structured processing → take action → generate a communication for review. It is the last step before a human, not a step that enables downstream automation. In n8n, a generation task produces a text string displayed in a review interface a form, a Slack message, an approval workflow before the text goes anywhere external.
Never send generated content directly to clients or external systems without a human review stage. The model will eventually produce content that is wrong, inappropriate, or embarrassing. The question is not whether it will happen but when. Every generation workflow requires an approval step before external delivery.
If the output text follows a fixed structure with only a few variable fields, use a template with field substitution rather than generation. Generation adds cost, latency, and unpredictability. Reserve it for genuinely personalized, context-sensitive communications where template substitution produces inferior results.
| Pattern | Input | Output | Phase 4.5 Use |
|---|---|---|---|
| Classification | Free-form text (e.g., support email body) | Category enum + confidence + signals | Projects P1, PA “Is this email a support or sales inquiry?” |
| Extraction | Free-form text (e.g., project brief) | Named fields (may be null) + confidence per field | Project PA (signals) “What budget figure did they mention?” |
| Enrichment ★ | Free-form text (e.g., inquiry message) | Numeric score + confidence + signals + reasoning | Project PB “How strong is this lead’s intent?” (Core Part II pattern) |
| Generation | Structured fields (e.g., lease record) | Free-form text (human review required before use) | Not used in Part I / Part II as primary pattern |
| Rules (no AI) | Structured fields (e.g., deal_size, contact_country, submission_date) |
Typed result (deterministic) | All IF routing, scoring rules, threshold checks |
Primary decision criterion: Does the decision depend on the MEANING of free-form text? - YES → Choose Classification, Extraction, Enrichment, or Generation based on output type needed - NO → Use a rule. Do not call AI.
Output type guide: - Need a CATEGORY (label)? → Classification - Need to PULL FACTS out of text? → Extraction - Need a JUDGMENT SCORE on a quality? → Enrichment - Need to PRODUCE new text? → Generation (+ human review)
1.1.5 The AI Suitability Framework
AI Suitability Framework
The AI suitability framework is a structured decision tool for evaluating any business automation problem and determining the correct processing approach. It produces three possible outputs: rule-only processing, AI-assisted processing, and human review. Identifying the correct output before building a single node is the most important judgment call in designing an AI-enhanced workflow.
The framework evaluates a problem across four sequential questions:
Question 1: Is the input structured? If all the data you need to make a routing or processing decision exists in typed, structured fields numbers, dates, booleans, enums, IDs use rules. Examples: routing by deal size, filtering by contact country, prioritizing by submission date. Do not call AI to re-evaluate data that already exists as a structured value.
Question 2: Does the decision require semantic interpretation of free-form text? If the relevant data is in a free-form text field and cannot be reliably extracted by pattern matching, AI is appropriate. Examples: assessing intent from an inquiry message, classifying the topic of a support ticket, extracting a budget figure from a project brief.
Question 3: Is the text sufficient for AI to produce reliable output? If the free-form text is too short (fewer than 15–20 words), too generic (“I have a question”), or clearly insufficient for the classification or enrichment task, bypass AI and route to human review. AI called on insufficient input produces low-confidence outputs that add noise rather than signal.
Question 4: Is the AI confidence sufficient? If the AI produces an output below the low-confidence threshold, route to human review. A low-confidence AI result is not better than no AI result it adds noise to the system and may misdirect downstream processing.
The framework produces this routing table:
| Condition | Processing Path |
|---|---|
| All fields structured; no free text needed | Rule-only |
| Free text present and meaningful; AI confident | AI-assisted |
| Free text present; AI produces low confidence | Human review |
| Free text too short or clearly insufficient | Human review (or rule-only default) |
| AI API unavailable or response invalid | Rule-only fallback + requires_manual_review flag |
| Required structured fields missing | Human review |
Figure 9.1 illustrates the four-question framework as a decision tree.
| Step | Question | If NO | If YES |
|---|---|---|---|
| Q1 | Are all required structured fields present and valid? | Human review incomplete submission | Continue to Q2 |
| Q2 | Is there meaningful free-form text that requires semantic interpretation? | Rule-only processing all fields structured, no free text needed | Continue to Q3 |
| Q3 | Is the free-form text sufficient for AI? (length > threshold, not clearly generic) | Human review text present but too thin for reliable AI output | Call AI: Build Prompt → HTTP Request (LLM) → Parse Response, then continue to Q4 |
| Q4 | Is AI confidence sufficient? (confidence ≥ 0.55) | Human review AI ran but confidence insufficient | AI-assisted processing combined score, audit log, downstream action |
In Part I, this framework is implemented as a Code node that evaluates each incoming record against these four questions and sets a processing_path field "rules", "ai", or "review" that a Switch node branches on. This makes the AI call an explicit, governed decision rather than an automatic default. In Part II, the same logic appears as the pre-flight validation Code node in Workflow A: before the Build Prompt node runs, the workflow checks whether the inquiry description is present, non-empty, and above the minimum length threshold. If not, ai_score_valid = false and the workflow proceeds on the rule-only path.
Key Principle
AI is warranted only when the decision requires semantic interpretation of meaningful free-form text. When the suitability check fires routing to rule-only or human review that is not a failure. It is the framework working as designed.
The suitability check matters most in production, where real users submit incomplete forms, type two words into the inquiry field, or paste the same message into every form they encounter. In testing, where submissions are crafted to exercise the AI layer, the check will rarely fire. Calibrate the minimum text length threshold against real submission data before deploying, and monitor the human review queue volume after launch. If the queue is consuming more manual effort than the AI is saving, the confidence threshold or length threshold needs adjustment.
The framework answers when to call AI. How the AI performs the task its role framing, evaluation dimensions, and output contract is engineered separately, in the prompt design discipline of Chapter 1.2 Prompt Engineering for Systems.
1.1.6 AI Limitations and Cost Considerations
Every AI limitation maps directly to an architectural pattern.
Large language models are powerful and unreliable simultaneously, and understanding their limitations is the prerequisite for designing systems around them. Every limitation here corresponds directly to an architectural pattern in Part I and Part II.
The most fundamental limitation is non-determinism: the same prompt sent twice to the same model may produce different outputs. temperature: 0.1 reduces but does not eliminate this variance. For workflows that run the same classification on similar inputs repeatedly, non-determinism means two submissions with nearly identical text may receive different scores on different days. The solution is not to eliminate non-determinism that is not possible above temperature: 0 but to design tier thresholds with sufficient buffer that near-identical inputs consistently route to the same tier.
Non-determinism produces a second limitation: confidence is approximate. The confidence field an LLM returns is the model’s estimate of its own certainty, which is itself probabilistic. A confidence of 0.80 does not mean the model is correct 80% of the time on high-confidence outputs. Use confidence as a relative routing signal high-confidence vs. low-confidence path not as an absolute accuracy guarantee.
Taken together, non-determinism and approximate confidence are why the confidence-band model uses three buckets rather than a continuous scale: bucket boundaries absorb the natural variance in both the output score and the confidence estimate.
Hallucination is a distinct failure mode from low confidence.
Hallucination is a distinct failure mode from low confidence. LLMs can produce confident-sounding outputs that are factually incorrect inventing signal labels not present in the text, producing an intent level that does not correspond to the textual evidence, or generating reasoning that describes features the text does not contain. High confidence does not immunize against hallucination. The signals array is the primary safeguard: if the model’s reasoning cites signals that are not in the source text, the output can be flagged in human review.
Three operational constraints govern how the AI layer behaves at scale.
Context window limitations mean that very long free-text inputs may exceed the model’s context window, increase cost significantly, or degrade output quality. Input truncation limiting the free-text field to 500 characters is both a cost control and a reliability control, not a quality trade-off. For classification and scoring tasks, 500 characters typically contain sufficient signal.
Rate limits and latency are scheduled operational events, not edge cases: in production workflows processing hundreds of submissions per hour, 429 rate limit errors will occur. Retry logic with backoff, combined with the rule-only fallback path, is the correct design response.
Cost is the final constraint approximately $0.00015 per call for gpt-4o-mini, operationally trivial for a professional system, but non-trivial if AI is called for every submission regardless of merit, including single-sentence inputs and clearly incomplete forms. The suitability framework is also a cost control.
The limitations and their architectural responses are directly related:
| Limitation | Part I Architecture Response |
|---|---|
| Non-determinism | temperature: 0.1; tier thresholds designed with buffer |
| Approximate confidence | Confidence bands as relative routing signals |
| Context window limits | Input truncation to 500 characters in Build Prompt node |
| Hallucination | Signals array in output schema; human review for low confidence |
| Rate limits | HTTP 429 retry (2 retries, 500ms backoff) + rule-only fallback |
| Cost | Pre-flight suitability check ensures AI is only called when warranted |
| Layer | Responsibility | Part I / Part II Examples |
|---|---|---|
| Deterministic Rules (base) | Handle structured data decisions reliably and cheaply. Should handle the MAJORITY of workflow decisions. | Scoring rules, governance checks, lifecycle routing, threshold comparisons |
| API Integrations | Connect systems, retrieve and write structured data. | Part I: OpenAI, Slack. Part II: HubSpot, Typeform |
| AI Classify | Add semantic intelligence for decisions that rules cannot make from structured data. | |
| AI Extract | Pull structured facts from free-form text. | Part I: signals array in all enrichment tasks |
| AI Enrich | Score qualities that require reading meaning. | Part I: Lead Intent Scorer (PB). Part II: Sec. 5.5 |
| AI Generate (apex) | Produce personalized text for human review. | Not used in Part I / Part II as primary pattern |
Design principle: Use the LOWEST layer that reliably solves the problem. Rules > APIs > AI. AI is the last resort, not the first response.
These limitations are not reasons to avoid AI they are the engineering requirements that define what Part I builds. Every architectural pattern in the chapters ahead is a direct response to one row in this table.
Practical Exercise 1.1 AI Suitability Routing Layer
The Chapter 1.0 recruiting workflow adds an AI classification step to every incoming application regardless of whether the cover letter is long enough, meaningful enough, or present at all. In production, a significant fraction of submissions will have cover letters that are too short or absent, which means the AI is called on insufficient input, produces low-quality outputs, and still incurs an API cost. The workflow needs a routing decision layer that evaluates each submission before the AI call and assigns it to the correct processing path.
The extended workflow structure:
[Webhook]
↓
[Code: Suitability Evaluation] ← NEW
↓
[Switch: processing_path] ← NEW
├─ "rules" → [Code: Rule Score] → [HTTP: Slack (rule-only notification)]
├─ "ai" → [Code: Build Prompt] → [HTTP: OpenAI] → [Code: Parse] → [HTTP: Slack (AI notification)]
└─ "review" → [HTTP: Slack (review queue notification)]
Step 1 Add the Suitability Evaluation Code Node
Purpose
The Chapter 1.0 workflow routes every submission to the AI call regardless of whether the cover letter is present, meaningful, or sufficient for AI analysis. This step inserts a deterministic Code node before Build Prompt that evaluates each submission against the four suitability questions and assigns a processing_path value. The AI call becomes conditional one branch of a deliberate routing decision rather than the automatic default. This node is also a cost control: submissions that do not warrant AI analysis bypass the API call entirely.
Operation Summary
| Property | Value |
|---|---|
| Node Type | Code (JavaScript) |
| Primary Function | Evaluate submission suitability and set processing_path for Switch routing |
| Input | candidate_name, email, applied_role, cover_letter_text from Webhook |
| Output | processing_path ("rules", "ai", or "review"), routing_reason, all input fields |
Insert a new Code node after the Webhook trigger and before the existing Build Prompt node. Name it Suitability Evaluation. Add the following:
// Read each submitted field (use empty string if not provided)
const name = ($json.candidate_name || "").trim();
const email = ($json.email || "").trim();
const role = ($json.applied_role || "").trim();
const cover = ($json.cover_letter_text || "").trim();
// Check whether each required field was filled in
const has_name = name.length > 0;
const has_email = email.length > 0;
const has_role = role.length > 0;
const required_fields_present = has_name && has_email && has_role;
// Count words in the cover letter (split on spaces, ignore empties)
const words = cover.split(" ");
let cover_word_count = 0;
for (let i = 0; i < words.length; i++) {
if (words[i].length > 0) {
cover_word_count = cover_word_count + 1;
}
}
const cover_is_meaningful = cover_word_count >= 15;
// Flag suspiciously short cover letters as possible spam
const is_spam_candidate = cover.length > 0 && cover.length < 10;
// Decide which processing path this submission should take
let processing_path;
let routing_reason;
if (!required_fields_present) {
// Build a readable list of which required fields are missing
let missing = [];
if (!has_name) { missing.push("name"); }
if (!has_email) { missing.push("email"); }
if (!has_role) { missing.push("role"); }
processing_path = "review";
routing_reason = "Required fields missing: " + missing.join(", ");
} else if (is_spam_candidate) {
processing_path = "review";
routing_reason = "Submission flagged: cover letter too short to evaluate";
} else if (!cover_is_meaningful) {
processing_path = "rules";
if (cover.length === 0) {
routing_reason = "No cover letter submitted rule-only scoring";
} else {
routing_reason = "Cover letter too short for AI (" + cover_word_count + " words) rule-only scoring";
}
} else {
processing_path = "ai";
routing_reason = "Cover letter present (" + cover_word_count + " words) AI classification warranted";
}
return {
json: {
candidate_name: name,
applied_role: role,
email: email,
cover_letter_text: cover,
cover_word_count: cover_word_count,
processing_path: processing_path,
routing_reason: routing_reason
}
};Implementation Logic
The node applies three sequential checks. First, it validates that name, email, and role are all non-empty required fields missing at intake means the submission cannot be processed by any path. Second, it checks whether the cover letter is too short to constitute a meaningful submission (under 10 characters triggers a spam heuristic). Third, it evaluates whether the cover letter meets the minimum word count (15 words) for AI analysis. Only submissions that pass all three checks receive processing_path = "ai". The routing_reason field records a human-readable explanation of the routing decision for the Slack notification and the audit record.
Output Table
| Output | Description |
|---|---|
processing_path |
"rules", "ai", or "review" consumed by the Switch node |
routing_reason |
Human-readable explanation of why this path was chosen |
cover_word_count |
Word count of the cover letter used in routing_reason and audit logging |
candidate_name |
Trimmed and validated replaces the raw Webhook value downstream |
email |
Trimmed and validated |
applied_role |
Trimmed and validated |
cover_letter_text |
Pass-through consumed by Build Prompt on the "ai" path |
This node encodes the suitability framework as a deterministic Code node that runs on every submission before any AI call is made. The result is a processing_path field "rules", "ai", or "review" that all downstream routing logic branches on. AI is not the default. It is one output of a deliberate routing decision.
Step 2 Add the Switch Routing Node
Purpose
The Switch node translates the processing_path field set by the Suitability Evaluation node into actual execution branching. Without this node, the suitability evaluation produces a field value that nothing in the workflow acts on the AI call would still execute for every submission. The Switch node is the architectural boundary that makes the three processing paths independent: nodes on the "ai" branch are unreachable from the "rules" and "review" branches, and vice versa.
Operation Summary
| Property | Value |
|---|---|
| Node Type | Switch |
| Mode | Rules-based |
| Primary Function | Route each submission to exactly one of three independent branches |
| Input | processing_path field from Suitability Evaluation node |
| Output | Three branch outputs: "rules", "ai", "review" |
Add a Switch node after the Suitability Evaluation Code node: - Mode: Rules-based - Route 1: processing_path equals "rules" → Rule Score branch - Route 2: processing_path equals "ai" → AI Classification branch - Route 3: processing_path equals "review" → Human Review branch
Decision Logic Table
processing_path Value |
Destination Branch | Condition Met |
|---|---|---|
"rules" |
Rule Score Code node | Cover letter absent or below word-count threshold |
"ai" |
Build Prompt Code node | Cover letter present and above word-count threshold |
"review" |
Slack (review queue) | Required fields missing or spam heuristic triggered |
The Switch node is the architectural boundary between the suitability decision and the execution paths. Each path from this point forward is independent: the AI classification nodes are only reachable via the "ai" path. The cost profile of the workflow is now predictable API calls occur only for submissions that pass the suitability check.
Step 3 Configure the Rule Score Branch
Purpose
Submissions on the "rules" path have no meaningful cover letter they passed the required-field check but did not provide sufficient text for AI analysis. Rather than producing no score, this branch computes a deterministic completeness score from the structured fields that are present and delivers a valid actionable output to the recruiter team. This demonstrates a key architectural principle: the rule-only path is not a degraded experience but the correct response to a submission that does not warrant semantic analysis.
Operation Summary
| Property | Value |
|---|---|
| Node Type | Code (JavaScript) |
| Primary Function | Compute a deterministic completeness score from available structured fields |
| Input | Validated candidate fields from Suitability Evaluation node |
| Output | rule_score (0–10), tier, ai_used: false |
Add a Code node on the "rules" branch. Name it Rule Score:
// Each field earns points the totals are the scoring weights
const name_score = ($json.candidate_name || "").length > 0 ? 3 : 0; // 3 points if present
const email_score = ($json.email || "").length > 0 ? 3 : 0; // 3 points if present
const role_score = ($json.applied_role || "").length > 0 ? 2 : 0; // 2 points if present
const cover_score = ($json.cover_letter_text || "").trim().length > 0 ? 2 : 0; // 2 points if present
const rule_score = name_score + email_score + role_score + cover_score; // max 10
// Assign a tier based on the total score
let tier;
if (rule_score >= 8) {
tier = "standard";
} else if (rule_score >= 5) {
tier = "review";
} else {
tier = "incomplete";
}
return {
json: {
candidate_name: $json.candidate_name,
applied_role: $json.applied_role,
processing_path: $json.processing_path,
routing_reason: $json.routing_reason,
rule_score,
tier,
ai_used: false
}
};Implementation Logic
Each field earns points toward a maximum score of 10: candidate_name (3 pts), email (3 pts), applied_role (2 pts), cover_letter_text non-empty (2 pts). The tier field maps the score to a routing bucket: "standard" for complete submissions, "review" for partially complete ones, "incomplete" for minimal submissions. ai_used: false is a flag that audit logging and Slack messages can read to distinguish rule-only outcomes from AI-assisted ones.
Output Table
| Output | Description |
|---|---|
rule_score |
Integer 0–10 based on field completeness |
tier |
"standard", "review", or "incomplete" |
ai_used |
Always false on this branch |
processing_path |
Pass-through for Slack notification |
routing_reason |
Pass-through for Slack notification |
Then add an HTTP Request node to Slack with the following message body:
*New Application Rule-Only Path*
Candidate: {{ $json.candidate_name }} | Role: {{ $json.applied_role }}
Score: {{ $json.rule_score }}/10 | Tier: {{ $json.tier }}
Reason: {{ $json.routing_reason }}
The rule-only path produces a valid, actionable output without an AI call. The recruiter sees the score, the tier, and the reason the submission bypassed AI. This is the fallback path working as designed not a degraded experience, but the correct response to a submission that doesn’t warrant semantic analysis.
Step 4 Connect the AI Classification Branch
Purpose
Submissions on the "ai" path meet all suitability requirements and proceed to the three-node AI pattern from Chapter 1.0. This step connects the Switch node’s "ai" output to the existing Build Prompt node and updates the Slack notification to surface the routing context alongside the classification result. The AI layer is not redesigned it is governed: the same nodes execute, but only when the suitability check determines the submission warrants them.
Operation Summary
| Property | Value |
|---|---|
| Branch Entry | "ai" output of Switch node |
| Primary Function | Execute the three-node AI pattern on qualified submissions |
| Nodes | Build Prompt → HTTP Request (OpenAI) → Parse Response → Slack |
| Change from Ch. 1.0 | Conditional execution only; Slack message includes routing_reason |
Connect the "ai" output of the Switch node to the existing Build Prompt Code node. Update the Slack notification at the end of the AI branch to include the routing context:
*New Application AI Assessed*
Candidate: {{ $json.candidate_name }} | Role: {{ $json.applied_role }}
AI Assessment: {{ $json.application_type }} ({{ $json.confidence_pct }}% confidence)
Signals: {{ $json.signals_text }}
Reason: {{ $json.routing_reason }}
The AI branch is exactly the same as the Chapter 1.0 implementation the only change is that it now executes conditionally. This is the correct pattern: the AI layer is not redesigned; it is governed. The suitability routing layer sits outside and above the AI call, deciding whether to invoke it at all.
Step 5 Configure the Human Review Notification
Purpose
Submissions on the "review" path have incomplete required fields or were flagged by the spam heuristic as potentially automated. Rather than dropping them silently or routing them into the standard queue without context, this branch delivers a specific Slack notification to the manual review queue with the routing reason visible. Human review is not a failure mode it is a defined processing path for submissions that genuinely require a human to evaluate.
Operation Summary
| Property | Value |
|---|---|
| Node Type | HTTP Request (Slack Incoming Webhook) |
| Method | POST |
| Primary Function | Route flagged submissions to the manual review queue with reason context |
| Input | candidate_name, applied_role, routing_reason from Suitability Evaluation |
| Output | Slack message posted to the review queue channel |
Add an HTTP Request node to Slack on the "review" branch:
*Application Requires Human Review*
Candidate: {{ $json.candidate_name || "Unknown" }} | Role: {{ $json.applied_role || "Unknown" }}
Reason: {{ $json.routing_reason }}
Action required: Manual review in ATS
Output Table
| Output | Description |
|---|---|
| Candidate name | "Unknown" if missing (required-field failure) |
| Applied role | "Unknown" if missing |
| Reason | Specific explanation from Suitability Evaluation |
| Action | Static text directing reviewer to ATS |
Human review is not a failure mode it is a defined processing path for submissions that genuinely require a human. Making it explicit in the workflow structure, with a specific Slack notification and a reason field, is what separates a governed system from one that drops incomplete submissions silently.
Technologies Used
| Component | Technology | Notes |
|---|---|---|
| Workflow automation | n8n | Extended from Chapter 1.0 |
| LLM API | OpenAI Chat Completions (gpt-4o-mini) |
Only called on the "ai" path |
| Notification | Slack Incoming Webhook | Three distinct notification formats |
| Routing | n8n Switch node | Routes on processing_path field |
Scope Boundary
This implementation adds the suitability routing layer and the three-path workflow structure. It does not yet include: the ai_result_valid validity flag and fallback path (Chapter 1.4 AI-Powered Workflow Design), confidence bands and contribution weighting (Chapter 1.5), requires_manual_review flag with audit logging (Chapter 1.5), or retry logic for API failures (Chapter 1.3 AI API Integration). The architecture emerging here a deterministic evaluation first, then a branching decision on whether AI is warranted, then the AI call itself is the structure of the full advisory architecture built progressively across the next four chapters.
Chapter Summary
The question this chapter answered when does AI belong in a workflow? is the most important judgment call in AI-enhanced automation engineering. The answer is precise: when the decision requires semantic interpretation of meaningful free-form text, and only then.
Classification, extraction, enrichment, and generation describe what AI can do for a business workflow that rules cannot. The capability pattern shapes the output schema, the validation logic, and the architectural position of the AI layer. Enrichment the pattern that produces a computed judgment score from unstructured text is the core pattern of Part I Project B and Chapter 2.5. The suitability framework governs when any of these patterns is invoked: a four-question decision that evaluates every submission before an API call is made and routes it to rule-only processing, AI-assisted processing, or human review.
The implementation in this chapter translates that framework into code. The AI classification nodes from Chapter 1.0 are unchanged; what changed is that they are now conditional. AI is not the default path. It is one branch of a deterministic routing decision that executes first, costs nothing, and determines whether the AI call is warranted at all.
Transition to Chapter 1.2
You now know where AI belongs in a workflow. The next challenge is communicating with it reliably enough that its outputs can be consumed by machine logic rather than read by a human.
Chapter 1.2 teaches prompt engineering for systems not as a conversational skill for getting useful responses from a chat interface, but as a technical discipline for producing a specific JSON schema with typed fields, valid ranges, and machine-parseable output. The prompt you will build in Chapter 1.2 is the same prompt Chapter 2.5 uses in its Build Prompt Code node. You will construct it technique by technique role assignment, output schema definition, field type constraints, confidence elicitation, evidence extraction until the prompt consistently produces the structured data your Code node expects.
Key Takeaways
- AI belongs in a workflow when and only when the decision requires semantic interpretation of meaningful free-form text. If the answer is in a structured field, use a rule.
- The four AI capability patterns classification, extraction, enrichment, and generation determine the output schema, the validation logic, and the architectural position of the AI layer.
- Classification maps free-form text to a typed enum value. Extraction pulls named facts from text. Enrichment produces a computed judgment score. Generation produces human-readable text for review.
- The AI suitability framework evaluates four questions before any API call: Are required fields present? Is meaningful free text present? Is the text sufficient for AI? Is the AI confidence sufficient?
- Low-confidence AI outputs do not proceed to automated downstream action they route to human review.
- Enrichment outputs must be bounded by a contribution cap and explained by a signals array. Both constraints are architectural requirements, not optional quality improvements.
- Generation always requires a human review stage before external delivery. Never route generated content directly to clients.
- Non-determinism, rate limits, hallucination, and cost are known constraints, not edge cases. Each one maps to a specific architectural pattern in Part I.
- The suitability framework is also a cost control: AI is called only on submissions that warrant it.
End of Chapter 1.1 AI in Business Operations