Architecture · Operations
AI Workflow Automation Architecture: Events, Orchestration And People In The Loop
The short answer
AI workflow automation runs a business process as a durable sequence of steps triggered by events. Ordinary code handles the steps with clear rules; language models handle the ones that need reading or judgement, returning structured output that code validates. A workflow engine keeps state, retries failures safely and sends exceptions to people, so the process runs straight through most of the time and visibly when it doesn't.
By Maitreya Kulkarni · Updated · 10 min read
01 · The architecture
What Does An AI Workflow Look Like End To End?
Events enter a queue that deduplicates them, a workflow engine runs each step with durable state, deterministic steps and AI steps do the work, people approve or correct where needed, and results land in your systems. Anything that keeps failing goes to a dead-letter queue to be fixed and replayed.
NX-AR-11 · Architecture
An AI workflow, reliably
- Outside world
- Data & integration
- AI agent
- Your people
- System of record
- L1
Triggers
(Outside world)Webhooks
. Hands work to: Event queue.Email and files
. Hands work to: Event queue.Schedules
. Hands work to: Event queue.
Passes down: events - L2
Ingest
(Data & integration)Event queue
Ordered, deduplicated by key
. Hands work to: Workflow engine.
Passes down: unique events - L3
Orchestrate
(Data & integration)Workflow engine
Durable state, retries, timeouts
. Hands work to: Deterministic steps, AI steps.
Passes down: steps - L4
Steps
(AI agent)Deterministic steps
APIs, rules, transforms
. Hands work to: Approvals and corrections.AI steps
Classify, extract, draft
. Hands work to: Approvals and corrections.
Passes down: results and exceptions - L5
People
(Your people)Approvals and corrections
Exceptions only
. Hands work to: Target systems, Audit log.
Passes down: resolved work - L6
Systems
(System of record)Target systems
ERP, CRM, helpdesk
Audit log
Dead-letter queue
Fix and replay
. Hands work to: Workflow engine.
02 · Workflow or agent
Should A Process Be A Workflow Or An Agent?
A workflow, whenever the steps are known. Workflows are cheaper, faster and easier to audit; agents earn their cost only when the path genuinely depends on what is found along the way. Most automation is a workflow with a few AI steps inside it.
| Question | Workflow | Agent |
|---|---|---|
| Are the steps known in advance? | WorkflowYes | AgentNo |
| Must every run be auditable step by step? | WorkflowEasily | AgentWith tracing |
| Is cost per run predictable? | WorkflowYes | AgentVaries |
| Typical examples | WorkflowInvoices, onboarding, reports | AgentResearch, open-ended support |
03 · Reliability
What Makes Automation Reliable?
Assuming every step can fail and designing so that failure is harmless. Idempotency makes retries safe, retries with backoff ride out temporary errors, durable state means nothing is lost when a process restarts, and a dead-letter queue keeps what still fails visible.
Idempotency keys
Each event and side effect carries a unique key, so a repeated delivery never charges or emails twice.
Retries with backoff and jitter
Waits grow between attempts and are randomised, so a recovering service isn't overwhelmed.
Durable state
The engine records progress after every step and resumes exactly where it stopped.
Dead-letter queues
Items that exhaust their retries are parked with the error for a person to fix and replay.
04 · AI steps
Where Should AI Sit Inside A Workflow?
Only where reading or judgement is needed, and always behind validation. AI steps return structured output against a schema, carry a confidence signal, and are checked by code before anything happens; anything doubtful becomes an exception rather than an action.
Structured outputs
Models fill a JSON schema rather than writing free text the next step must parse.
Validation in code
Totals add up, dates are valid, IDs exist, before the result is used.
Right-sized models
Small, fast models for classification; stronger ones only for drafting and judgement.
05 · Engines
How Do You Choose A Workflow Engine?
By who maintains it and how critical the process is. Visual tools suit fast iteration by operations teams; code-first durable engines suit critical, high-volume processes; simple queues suit narrow jobs.
| Engine | Strengths | Best for |
|---|---|---|
| n8n | StrengthsVisual, self-hostable, many integrations, AI nodes | Best forOperations-owned automations |
| Temporal | StrengthsCode-first, durable execution at scale | Best forCritical, long-running processes |
| Queue workers | StrengthsSimple, cheap, full control | Best forNarrow, high-volume jobs |
| Zapier or Make | StrengthsFastest to start | Best forLight, low-volume tasks |
The ecosystem
n8n
OpenAI
Claude
PostgreSQL
Redis
Cloudflare


