Skip to content

Lesson 230·M22 AI Automation

AI Automation Architecture

Open

Learning Objectives

By the end of this lesson you should be able to:

  • Draw the platform spine: events → workflows → queues → gates → record (L230)
  • Explain the layers: triggers (L220–221), workflows (L217), queues (L222)
  • Explain the gates' place: the trust control at the consequential points (L228)
  • Explain the observability: the platform's record (L213)
  • Explain how the tools and integrations plug in (L218–227)

One-Line Definition

AI automation architecture is the platform spine that makes automation a system — events in (webhooks, L220, schedules, L221), workflows (the unit, L217), queues (the engine room, L222), approval gates (the trust control, L228), and the record (the trace, L213) — the shape every tool (L218–219) and integration (L223–227) plugs into, and the assembly that turns scattered scripts into a platform (L230).

The one-sentence interview answer: "The automation architecture is a spine of five layers (L230). Events in — the webhooks (L220) and the schedules (L221): the business talks to the platform (L220). Workflows — the unit (L217): the AI and rule steps with the contracts (L163). Queues — the engine room (L222): every workflow runs on the queue (L222), never in a request (L222). Approval gates — the trust control (L228): the consequential steps wait for the human (L208). And the record — the trace (L213): every run, decision, and token is recorded (L332), serving the audit (L322) and the recovery (L232). Every tool (L218–219) and integration (L223–227) plugs into this spine (L230). The platform is the assembly — events in, workflows, queues, gates, and the record — that turns scattered scripts into a system (L230)."

Mental Model

Think of the automation platform as a well-run postal service. The post (the events) arrives at the sorting office (the event layer, L220–221): the letters from the businesses (webhooks, L220) and the scheduled rounds (cron, L221). The mail is sorted into routes (the workflows, L217) — each route is a sequence of stations (the steps, L163). The carts (the queues, L222) carry the mail between the stations, so the office never blocks on a slow station (L222). The insured parcels (the consequential steps, L228) need a signature at the counter (the approval gate, L208). And every parcel's journey is logged in the ledger (the trace, L213). The postal service works because the sorting, the routes, the carts, and the signatures are one system (L230).

   the postal service (the platform, L230)
   ┌──────────────┐   ┌──────────────┐   ┌──────────────┐   ┌──────────────┐
   │ events in    │ → │ workflows    │ → │ queues       │ → │ gates        │
   │ (L220-221)   │   │ (L217)       │   │ (L222)       │   │ (L228)       │
   └──────────────┘   └──────────────┘   └──────────────┘   └──────────────┘
                             │ the record (L213) — every journey logged
                             └──────────────────────────────────────────┘

The mental model is the postal service: the sorting, the routes, the carts, the signatures, and the ledger — one system (L230).

Visual Flow — The Platform Spine

   the business's events (L223-227)
        │
        ▼
   ┌──────────────────────────────────────────────────────────┐
   │ 1 · EVENTS IN (L220-221)                                 │
   │     webhooks (L220) · schedules (L221) — the triggers    │
   └──────────────────┬───────────────────────────────────────┘
                      ▼
   ┌──────────────────────────────────────────────────────────┐
   │ 2 · WORKFLOWS (L217)                                     │
   │     the unit: the AI (L163) + rule (L199) steps with     │
   │     the contracts (L143)                                 │
   └──────────────────┬───────────────────────────────────────┘
                      ▼
   ┌──────────────────────────────────────────────────────────┐
   │ 3 · QUEUES (L222)                                        │
   │     the engine room: every run enqueued, workers process │
   │     (L222), retries (L169), dead letters (L232)          │
   └──────────────────┬───────────────────────────────────────┘
                      ▼
   ┌──────────────────────────────────────────────────────────┐
   │ 4 · GATES (L228)                                         │
   │     the consequential steps wait for the human (L208)    │
   └──────────────────────────────────────────────────────────┘
                      ▼
   the RECORD (L213) — every run, decision, token — the audit
   (L322) and the recovery (L232) read the same record

The flow is the spine: events → workflows → queues → gates → record — the platform's anatomy (L230).

How It Works — The Five Layers

  • Events in (L220–221). The triggers: the webhooks (L220) — the business talks to the platform — and the schedules (L221) — the recurring work (L230). Each trigger enqueues (L222), never runs inline (L220).
  • Workflows (L217). The unit: the AI (L163) and rule (L199) steps with their contracts (L143) and their gates (L228) — the L217 line, built from the L229 map (L229).
  • Queues (L222). The engine room: every workflow runs on the queue (L222) — the retries (L169), the dead letters (L232), and the idempotency (L255) live here (L230).
  • Gates (L228). The trust control: the consequential steps wait for the human (L208), with the request's context (L203) and the audit (L322).
  • The record (L213). The trace: every run, decision, and token (L332) — serving the debugging (L211), the audit (L322), and the recovery (L232).

Note

The platform is the layers composing — and the tools plug into the spine (L230). n8n (L218) and Make (L219) implement the workflow layer (L217); the CRM, email, Slack, database, and API integrations (L223–227) are the workflow's steps (L230); the queues (L222) and the gates (L228) are the platform's own layers (L230). The senior design keeps the spine (L230) independent of the tools (L218): the workflow layer is swappable (L155), the integrations are contracts (L163), and the platform — events, queues, gates, record — is the constant (L230).

Real Project Usage

  • Support automation. The ticket webhook (L220) → the triage workflow (L217) → the queue (L222) → the refund gate (L228) → the record (L213).
  • Sales automation. The CRM lead event (L223) → the scoring workflow (L217) → the enrichment (L163) → the follow-up gate (L228).
  • Finance automation. The payment event (L227) → the reconciliation workflow (L217) → the approval gate (L228) → the record (L322).
  • Scheduled operations. The nightly digest (L221) → the summarization workflow (L217) → the queue (L222) → the post (L225).
  • Anything the business runs (L230). The spine is the platform (L230) — every process (L229) and integration (L223–227) plugs in (L230).

The through-line: the spine is the platform — events, workflows, queues, gates, and the record — and every tool and integration plugs into it (L230).

Interview Explanation

Say it in four moves:

  1. The spine. "Events in (L220–221) → workflows (L217) → queues (L222) → gates (L228) → record (L213)."
  2. The layers. "The triggers enqueue (L222); the workflows are the unit (L217); the queue is the engine room (L222)."
  3. The gates. "The consequential steps wait for the human (L208, L228)."
  4. The record. "Every run and decision traced (L213) — the audit (L322) and the recovery (L232) read the same record."

Senior-Level Insights

  • The spine is the architecture; the tools are implementations (L230). The senior answer designs the five layers (L230) and fits n8n (L218) or Make (L219) into the workflow layer (L217) — the platform is the constant (L230).
  • The queue is the platform's heart (L222). Every run enqueued (L222), the retries (L169), the dead letters (L232) — the engine room is what makes the workflows asynchronous (L230).
  • The gates are the trust control (L228). The consequential steps wait (L208) — the gate layer is the platform's trust (L324).
  • The record is the platform's memory (L213). The trace (L213) serves the debugging (L211), the audit (L322), and the recovery (L232) — the record is the platform's accountability (L230).
  • The integrations are contracts (L163). The CRM (L223), email (L224), Slack (L225), database (L226), and API (L227) integrations are steps with contracts (L163) — swappable (L155), testable (L341), composable (L230).

Common Mistakes

  • Scattered scripts (L230). The workflows in scripts, no spine (L217) — no queue (L222), no gates (L228), no record (L213).
  • The tool as the platform (L218). The n8n or Make canvas (L219) replacing the spine (L230) — the platform's layers skipped (L222).
  • Work in the trigger (L222). The event handler running the workflow inline (L151) — the queue bypassed (L220).
  • No gate layer (L228). The consequential steps running (L324) — the trust control missing (L230).
  • No record (L213). The runs and decisions untraced (L322) — the platform unaccountable (L230).
  • The integrations as code (L163). The CRM and API calls scattered (L227) — the contracts (L163) missing, the layers coupled (L230).

Best Practices

  • Draw the spine first (L230) — events, workflows, queues, gates, record (L217).
  • Enqueue, never inline (L222) — the triggers hand to the queue (L220).
  • Keep the tools in the workflow layer (L218) — the spine stays tool-independent (L155).
  • Gate the consequential (L228) — the trust control at the risk points (L212).
  • Record everything (L213) — the trace serves the audit (L322) and the recovery (L232).
  • Contract the integrations (L163) — the steps' inputs and outputs defined (L143).

Interview Questions

Q: What's the shape of an automation platform?

A: A spine of five layers (L230). Events in — the webhooks (L220) and schedules (L221). Workflows — the unit (L217): the AI and rule steps with contracts (L163). Queues — the engine room (L222): every run enqueued, workers process (L222), retries (L169). Gates — the trust control (L228): the consequential waits for the human (L208). And the record (L213) — every run and decision traced (L332), serving the audit (L322) and the recovery (L232).

Q: Why is the queue the platform's heart?

A: Because it's what makes the workflows asynchronous (L222). The triggers enqueue and return fast (L220, L151); the workers process on the queue (L222); the retries (L169) and the dead letters (L232) live there. Without the queue, every workflow runs in the trigger (L222) — slow responses (L151) and no failure story (L232). The engine room is the platform's async heart (L230).

Q: Where do the tools fit?

A: In the workflow layer (L218). n8n (L218) and Make (L219) implement the L217 unit — the canvas of steps (L217). The spine — events (L220), queues (L222), gates (L228), the record (L213) — is the platform's own (L230). The senior design keeps the spine tool-independent (L155): the workflow layer is swappable, and the platform is the constant (L230).

Q: How do you keep the platform accountable?

A: The record (L213). Every run, every decision, every token is traced (L332) — the debugging (L211), the audit (L322), and the recovery (L232) all read the same record (L213). The gates (L228) record their decisions; the queue (L222) records its jobs; the workflows (L217) record their steps. The platform is accountable because it's recorded (L230).

Follow-Up Questions

  • What are the five layers (L230)?
  • Why is the queue the heart (L222)?
  • Where do the tools fit (L218)?
  • How do the gates compose (L228)?
  • What does the record serve (L213)?

Comparison Table — Scripts vs Platform

Scattered scripts (L230)Platform (this lesson)
Events (L220)ad-hocwebhooks + schedules, unified
Workflows (L217)scriptsthe unit, with contracts (L163)
Queues (L222)inlinethe engine room (L222)
Gates (L228)nonethe trust control (L208)
Record (L213)logsthe trace — debug, audit, recovery
The spine (L230)nonethe five layers

The senior read: the right column is the platform — the assembly that turns automation into a system (L230).

Code Example — The Spine

// The automation platform: events → workflows → queues → gates → record (L230).
// EVENTS IN (L220-221) — the triggers enqueue, never inline (L222).
export async function webhook(req) {
  const event = verifyAndValidate(req);                 // L212, L163
  if (await dedupe(event.id)) return ok();              // L255
  await queue.enqueue({ type: 'workflow.run', workflow: 'support-triage', event });  // L222
  return ok();                                          // fast (L151)
}

// THE QUEUE (L222) — the engine room.
async function worker() {
  for (const job of await queue.dequeue()) {
    try {
      const result = await runWorkflow(job);            // L217 — the unit
      await record(job, result);                        // THE RECORD (L213)
      await queue.ack(job.id);
    } catch (e) { await retryOrDeadLetter(job, e); }    // L169, L232
  }
}

// THE GATE (L228) — the trust control inside the workflow (L217).
async function runWorkflow(job) {
  const steps = workflow.steps;                         // the L229 map (L229)
  let data = job.event;
  for (const step of steps) {
    if (step.kind === 'risk') {
      data = await approvalGate(step, data);            // L208 — waits for the human
    } else {
      data = await step.run(data);                      // rule (L199) / AI (L163)
    }
    await record({ step: step.id, data });              // THE RECORD (L213)
  }
  return data;
}

// THE RECORD (L213) — the platform's memory.
async function record(event) {
  await trace.write(event);                             // the audit (L322), the recovery (L232)
}
What the reader must SEE — the spine, in code:

  webhook → enqueue   → events in (L220) + the queue (L222)
  worker → runWorkflow → the unit on the engine room (L217, L222)
  kind: 'risk' → gate → the trust control (L228)
  record() every step → the platform's memory (L213)

  Events, workflows, queues, gates, record — the five layers.

Tip

The line that defines the platform: if (step.kind === 'risk') data = await approvalGate(...) — the gate inside the workflow (L228). The spine is the five layers composing; the gate is where the human sits (L230).

Performance Notes

  • The queue is the throughput control (L222). The engine room (L222) absorbs the event bursts (L151) — the workers scale (L222).
  • The record is the storage cost (L150). The trace (L213) is the platform's memory (L322) — cheap, required, retained by policy (L373).
  • The gates are the human's latency (L151). The consequential waits (L208) — the platform's wall-clock includes the approvals (L228).
  • The AI steps are the token cost (L150). The judgments (L163) are the workflows' spend (L149) — budgeted per workflow (L230).

Debugging Scenarios

SymptomLikely causeFirst thing to check
Workflows run inlineThe queue bypassed (L222)Enqueue in the triggers (L220)
Consequential runsThe gate missing (L228)The risk steps' gates (L208)
No auditThe record absent (L213)Trace every run and decision (L322)
Tools as the platformThe spine skipped (L218)The five layers (L230)
Recovery is chaosNo dead letters (L232)The engine room's story (L222)

Quick Revision Notes

  • The platform = the five-layer spine (L230): events, workflows, queues, gates, record.
  • Events in: webhooks (L220) + schedules (L221), enqueuing (L222).
  • Workflows: the unit (L217) with contracts (L163) and gates (L228).
  • Queues: the engine room (L222) — retries (L169), dead letters (L232).
  • Gates: the trust control (L228) — the human at the consequence (L208).
  • The record: the trace (L213) — debug (L211), audit (L322), recovery (L232).

Cheat Sheet

AI AUTOMATION ARCHITECTURE = the five-layer spine

THE SPINE (L230)
  1 events in   webhooks (L220) · schedules (L221) — the triggers
                verify (L212) · dedupe (L255) · ENQUEUE (L222)
  2 workflows   the unit (L217) — AI (L163) + rule (L199) steps
                the contracts (L143) · the L229 map (L229)
  3 queues      the engine room (L222) — retries (L169),
                dead letters (L232), idempotency (L255)
  4 gates       the trust control (L228) — the consequential
                waits for the human (L208)
  5 record      the trace (L213) — every run, decision, token
                (L332) — the audit (L322) and the recovery (L232)

THE RULES
  triggers enqueue, never inline (L222)
  the tools (L218-219) plug into the workflow layer (L217)
  the integrations (L223-227) are steps with contracts (L163)
  the spine is the platform — tool-independent (L155)

INTERVIEW, 4 MOVES
  1 spine   "events → workflows → queues → gates → record"
  2 layers  "the unit (L217), the engine room (L222)"
  3 gates   "the human at the consequence (L228)"
  4 record  "the platform's memory (L213)"

Key Takeaways

Recap

  • AI automation architecture is the five-layer spine (L230): events in (L220–221), workflows (L217), queues (L222), gates (L228), and the record (L213)
  • Events in are the triggers (L220–221) — verified (L212), deduplicated (L255), and enqueued (L222), never run inline
  • The queue is the engine room (L222) — retries (L169), dead letters (L232), and idempotency (L255) make the workflows asynchronous (L230)
  • The gates are the trust control (L228) — the consequential steps wait for the human (L208), with the request's context (L203)
  • The record is the platform's memory (L213) — the trace serves the debugging (L211), the audit (L322), and the recovery (L232)
  • The tools and integrations plug into the spine (L230) — n8n/Make (L218–219) in the workflow layer (L217), the CRM/email/Slack/DB/API (L223–227) as contracted steps (L163), and the spine itself tool-independent (L155)

Check your understanding

Answer each one out loud. Then rate yourself honestly.

0/8
1

What are the five layers (L230)?

2

Why do the triggers enqueue (L222)?

3

Why is the queue the engine room (L222)?

4

Where does the human sit (L228)?

5

What does the record serve (L213)?

6

Where do the tools fit (L218)?

7

How do the integrations plug in (L163)?

8

Why is the spine tool-independent (L155)?

A Closing Note — The Postal Service That Runs the Business

You now hold the platform: the events that enter, the workflows that process, the queue that keeps it async, the gates that keep it trusted, and the record that keeps it accountable. The scattered scripts are now a system — the five layers, composed (L230).

Next: the loop inside the line — multi-agent automation (L231), agents inside workflows.