PTENES
MODULE 1.3

✨ From “It Works” to “It Works Well”: Enhancement

Turn a workflow that “passes the tests” into one that's ready for the real world. You'll learn the layered enhancement philosophy, priority order, and six concrete improvements—from a no-match fallback to a confidence indicator—one change at a time.

8
Topics
~55
Minutes
Inter.
Level
Polish
Type
Module progress 0% · 0 of 8

Enhancement isn’t a leap: it’s a ladder. You climb one step at a time — first what breaks, then what's inefficient, then output quality and only then the performance. The diagram shows this priority order, from the bottom (errors) to the top (speed).

1 · Error what breaks 2 · Logic what’s inefficient 3 · Output the experience 4 · Performance the speed at each step: retest the happy path, test the fix, and confirm nothing else broke

Illustrative diagram — conceptual recreation of the enhancement order, not a real screenshot.

1

🪜 Layered Enhancement Philosophy

What it is: a workflow that “works” is basic and has no apparent errors; one that “works well” handles edge cases, provides a good user experience, and is efficient. The enhancement philosophy is to close that gap in layers — one change at a time, in steps, so you don’t get overwhelmed.

✓ Works WELL

  • ✓Edge cases handled (no match, automatic email).
  • ✓Good experience: formatting, signature, tone.
  • ✓Efficient from trigger to draft.

✗ Just “It Works”

  • ✗Breaks on the first case outside the happy path.
  • ✗Responds even to automated and no-reply emails.
  • ✗Raw output, with no brand voice or personalization.

🧭 Why learn

Enhancement is iterative and fluid: do the essentials first, keep a list of “nice to haves,” gather real-world feedback, demo it to a small group, and only then apply new rounds of changes. Cleanup is enhancement too — organizing, labeling, and even coloring overlapping nodes counts.

🎯 Practical tip

Test everything after every change and save/ back up as you go. Re-test the happy path, test the edge case you fixed, and confirm nothing else broke.

Key concepts

In layers

One change at a time.

Always test

After each step up.

Backup

Save your progress.

Smooth

Real-world feedback.

2

📊 Priority Order

What it is: there's a clear order for enhancement— error → logic → output quality → performance. First, what breaks; then, what’s inefficient; then, the experience; and finally, speed. Skipping this order wastes time.

The four steps, in order

1

Error handling—what breaks

Cases that cause the workflow to fail or produce the wrong response. They come first: a beautiful email is useless if no email (or the wrong email) is generated.

2

Logic improvements — what’s inefficient

Rules that could be smarter: filter old emails, ignore automated messages, branch when there’s no match.

3

Output quality — the experience

How the result feels: email formatting, brand voice, signature, personalization with the customer's name.

4

Performance—the speed

How quickly it goes from trigger to draft. Optimize last, once everything else is correct and polished.

🧭 Why learn

Always confirm that the happy path still works before and after to change—so you don’t blame your new change for a breakage that already existed. This order prevents polishing something that isn’t reliable yet.

Key concepts

1. Error

What breaks.

2. Logic

What is inefficient.

3. Output

The experience.

4. Performance

Speed.

3

🛟 No-match fallback

What it is: when the vector store can’t find it a policy for responding, the agent shouldn’t make anything up. The solution: the agent emits a confidence marker (“policy found” / “no policy”), a code node interprets it, a IF branches off, and a new polite draft says "let’s research this and get back to you".

Fallback chain (illustrative example)
agente → marcador: "no policy found"
   ↓
nó de código → lê o marcador
   ↓
IF → política encontrada?
   ├─ sim → rascunho normal
   └─ não → rascunho "vamos pesquisar
            e retornar" (bem formatado)

🧭 Why learn

It's the #1 defense against hallucinations. Anticipate the clarifying questions (match threshold, fallback message, relevance score) before requesting the change. And verify: a question about "international shipping" should go to the research draft, never to an invented answer.

🎯 Practical tip

Test with a question that's probably out of scope and confirm that the fallback draft appears—not a hallucination. Bonus: that draft is usually better formatted, with paragraphs and line breaks.

Key concepts

Marker

Trust in the system prompt.

Code node

Interprets the marker.

IF

Branches the flow.

Extra draft

“Let’s research.”

4

⏱️ Time-based filtering

What it is: process emails only newer than X minutes, so you don't reprocess old inboxes. Instead of adding a time-check node, the AI discovers Gmail's search syntax and adds a filter “newer than” directly in the trigger.

Filter in the Gmail trigger (illustrative example)
# pedido em linguagem natural:
"Processe só e-mails dos últimos 10 minutos."

# a IA adiciona ao gatilho:
query: newer_than:10m
# sem nó separado de checagem de tempo

✓ Advantage

  • ✓Filter directly in the trigger—no extra node.
  • ✓Doesn’t reprocess old emails in the inbox.
  • ✓Lighter and faster to run.

✗ What to Avoid

  • ✗Create a redundant time-check node.
  • ✗A window so short that it misses emails between runs.
  • ✗A window so wide that it reprocesses and duplicates.

🧭 Why learn

Shows that AI often finds a more elegant approach than the obvious one—using Gmail’s native query instead of a node. Aligning the time window with the polling interval prevents missing or duplicating emails.

Key concepts

newer than

Gmail syntax.

In the trigger

No separate node.

Window

Align it with polling.

Efficiency

Less reprocessing.

5

🚫 Filtering automated emails

What it is: not every email deserves a reply. A code node after the trigger detects out-of-office messages, delivery notifications, newsletters, and no-reply/postmaster/bounce/marketing senders, add a boolean isAutomated and the reason, and branches to skip. This creates three gates: automatic? → support? → policy match?

⚠️ The case-sensitivity trap

A classic bug: the filter let a sender through no-reply@ because the code read the header fields in lowercase, but they arrived capitalized. The fix: compare the two cases. A case-sensitive header silently breaks filters.

# falha: header.toLowerCase() vs "No-Reply@..."
# corrige: comparar lower E original

🧭 Why learn

Avoid absurd drafts (responding to a "delivery complete") and wasting tokens. When multiple workflows are visible to the AI, name the existing workflow in the request—a vague request may lead the AI to create a new workflow from scratch.

🎯 Practical tip

To test a filter, you need to send exactly that type of email. If an automated email gets through, copy the issue back to the AI and have it fix the case sensitivity; reload n8n and test again.

Key concepts

isAutomated

Boolean + reason.

3 gates

Auto → support → match.

Case

Compare the two cases.

Name it

The existing workflow.

6

🗣️ Brand voice/tone

What it is: adjust the tone of the responses to be friendly, helpful, casual, and enthusiastic. The change is made in two places: the AI agent's system prompt (technical answers) and the fallback draft, "let's look that up." Here we enter the output quality layer.

🎨 What goes into the system prompt

  • •Greeting and opening style.
  • •Tone guidelines (“tech-savvy, but never condescending”).
  • •Encouraging phrases and varied sign-offs.

🧭 Why learn

Tone is what makes the response sound "like the company" and not "like a generic robot." Be specific and reference the existing workflow for the AI to edit it instead of building a new one. Updating both places (agent and fallback) keeps the voice consistent on either path.

🎯 Practical tip

After applying it, send a test email and read the draft as if you were the customer: does it have the personality? Is the tone consistent between the technical response and the fallback?

Key concepts

Two places

Agent + fallback.

Tone

Friendly and clear.

Specific

Reference the workflow.

Consistent

On every path.

7

👤 Personalization with the Customer’s Name

What it is: extract the customer's name from the signature/closing from the email (patterns like "Best, João" / "Thank you, Sara"), store it in a variable, and use it in the greeting—with a fallback “Hello” when there’s no subscription. A new code node handles the extraction; the agent prompt and the two drafts then use the name.

Name extraction (illustrative example)
padrões: "Abraços, João" / "Obrigada, Sara"
   ↓
variável nome = "João"
   ↓
saudação: "Olá João," # ou "Olá" se vazio

⚠️ Why learn — "that's why you test"

The extraction/fallback logic may behave unexpectedly: without a signature, it may end up using the email address name instead of "Hello." Test with extreme inputs. The AI may also make unrequested adjustments (repositioning nodes)—review them.

🎯 Practical tip

Send one test email with a clear signature and another without one. Confirm the personalized greeting in the first and the “Hello” fallback (not the email name) in the second.

Key concepts

Extraction

From the subscription.

Variable

Reused in drafts.

"Hello" fallback

Without a name → generic.

Extreme test

With and without a subscription.

8

🟢 Trust Indicator

What it is: a high/medium/low badge based on the score showing how well the knowledge base matched — for internal review, appended to the end of the draft. The agent emits the marker (e.g., high > 0.8; medium 0.6–0.8; low < 0.6); a code node interprets it and builds an HTML badge (green/yellow/red, gray when there's no match).

📶 The trust scale

High

score > 0.8

Intermediate

0,6 – 0,8

Low

score < 0.6

None

no match

🧭 Why learn

The badge gives the human reviewer a quick signal of how much to trust the draft before sending it—without reading everything. As with the other improvements, anchor your request in the named existing workflow for the AI to edit instead of recreate. It’s an example of output quality tailored to the person operating the agent.

🎯 Practical tip

Test with a price-match email (usually a partial match) to see the medium/low badge appear. The badge is internal: it guides the review; it isn't shown to the customer.

Self-healing (optional): what should be the FIRST enhancement step, before the others?

📌 Module Summary

✓
Layered enhancement — one change at a time; "works" vs. "works well".
✓
Priority order — error → logic → output quality → performance.
✓
Errors & logic — fallback when there’s no match, time filter, filter out automated messages (case!).
✓
Output quality — brand voice, client name, trust indicator.
✓
Golden rule — back up, test after each change, and anchor to the existing workflow.

Next Track:

Track 2 — Mastering the Code Agent: agentic workflows, the WAT framework, MCP, skills, and token management.