AI Workflow Automation: How to Design Workflows Around a Language Model
By Abhishek Patoliya · 2026-08-11
An AI workflow is an ordinary automated process in which one or more steps use a language model to read, judge or write. That framing matters because most of the work, and most of the failures, sit in the ordinary parts: where the input comes from, what the model is allowed to decide, what happens when it is unsure, and how anyone finds out what went wrong. This first lesson of the AI Automation Foundations path gives you a design method you can apply on paper before choosing any tool, and a worked example that takes one process from "someone reads every email" to a design document you could hand to a builder.
You don't need any programming experience for this lesson. You need one repetitive process from your own work in mind.
The six parts of every AI workflow
| Part | Question it answers | Example (support inbox) |
| Trigger | What starts a run? | A new email arrives in support@ |
| Context | What information does the decision need? | Email text, sender, the customer's plan and open orders |
| AI step | Which part needs reading, judgment or writing? | Classify the request and extract an order number |
| Rules | What can be decided without a model? | "Refund over $200 goes to a senior agent" |
| Action | What changes in the world? | Ticket created, tagged, assigned; draft reply saved |
| Record | How will you know what happened and why? | Input, model output, rule applied, action taken, per run |
If you can't fill in a row for your process, that gap is the first thing to resolve, not something the model will figure out.
Workflow or agent?
Anthropic's engineering guide Building effective agents draws a useful line: in a workflow, models and tools are orchestrated through code paths you define in advance; in an agent, the model decides its own steps and which tools to use. The guide's advice is to start with the simplest design that works and add autonomy only when it demonstrably improves results.
For most business processes that means a workflow. A step needs an agent only when you can't draw its branches in advance, for example researching an unfamiliar company where the next search depends on what the last one found. If you can draw the flowchart, build the flowchart. The trade-offs are covered in depth in AI agent vs workflow: when not to use an agent.
The design method
1. Map the process as it really runs today
Sit with the person who does the work and write down each step, including the checks nobody documented ("I always look at the order history first"). Those unwritten checks are what an automation breaks on day one. The next lesson, how to choose which tasks to automate, gives you a full mapping and scoring method.
2. Mark each step: rule, model, or person
For every step ask: could I write this down as an exact rule? If yes, it's a rule; rules are cheaper, faster and testable. If the input is free text whose meaning has to be understood, it's a model step. If the step carries consequences someone must answer for (money leaving, a person being refused), a person decides, possibly with a model preparing the information. Lesson 3 covers the rule-versus-model decision in detail.
3. Specify each model step like a function
Vague AI steps ("let the AI handle it") are where workflows become unpredictable. Write each one down with a fixed input, a fixed output shape, the allowed values, and what happens when the model is unsure:
Step: classify_support_email
Input: subject, body (plain text, max 8,000 characters), customer_plan
Output (JSON):
category: one of ["billing", "refund", "bug", "how_to", "other"]
order_number: string matching ^ORD-\d{6}$, or null
confidence: "high" | "low"
reason: one sentence, for the log only
If the output is not valid JSON, or category is not in the list → treat as low confidence
If confidence is "low" → route to the human triage queue, do not act
Asking for a fixed JSON shape (most model APIs and n8n's AI nodes support structured output) and validating it before use turns a free-text answer into something your rules can safely act on. See structured outputs vs freeform text and validating LLM output against a schema.
4. Design the exception paths before the happy path is finished
For each step, decide in writing what happens when:
- the input is missing something (no order number, an empty email);
- the model's output is invalid or low-confidence;
- an external system is down or slow;
- the same event arrives twice (email providers and webhooks do resend);
- the input is hostile, such as an email containing instructions aimed at the model.
The usual answer is "send it to a person with the context attached", which is fine. The failure mode to avoid is a workflow that silently does nothing. Duplicate events are covered in idempotent AI automation.
5. Put people where the risk is
Start with a person approving every consequential action, then relax review as evidence accumulates: auto-approve high-confidence billing questions once you have seen enough of them handled correctly, keep refunds under review. Human-in-the-loop AI workflows shows how to add approval steps without creating a bottleneck.
6. Record every run
Log the input (or a reference to it), the model's raw output, which rule fired, and the action taken. Without this you can't answer the first question anyone asks after a mistake: "why did it do that?" AI automation observability lists what to capture.
Common workflow patterns
Most AI workflows are combinations of a few shapes. The names in brackets are the ones Anthropic's guide uses.
| Pattern | What it does | Main risk to design for |
| Classify and route (routing) | Model labels an item; rules send it down a path | Wrong label sends work to the wrong place: keep a low-confidence path |
| Extract and sync | Model turns a document or email into fields; fields are written to a system | Invented or misread values: validate formats and totals before writing |
| Draft and approve | Model writes a first draft; a person edits and sends | Reviewers rubber-stamping: measure how often drafts are changed |
| Summarise and notify | Model condenses long content for the people who need it | Omissions: link to the source so readers can check |
| Step-by-step chain (prompt chaining) | One model step's output feeds the next, with checks between | Errors compounding: validate between steps |
| Generate and check (evaluator-optimizer) | One step produces, another checks against criteria | Cost and latency of the extra calls |
Worked example: a support inbox
This is an illustrative design, not a report of a deployed system. Today one person reads every email to support@, looks up the customer, tags the request, and either answers it or forwards it.
- Trigger: new email in support@.
- Rule: ignore auto-replies and messages from our own domain (header and sender checks, no model).
- Context: look up the sender in the customer database; attach plan and the last three orders.
- Model step:
classify_support_email as specified above.
- Rules: low confidence → triage queue.
refund → refunds queue, never auto-answered. how_to with high confidence → continue to step 6. Everything else → the matching team queue.
- Model step: draft a reply for
how_to questions using only the help-centre articles supplied in the prompt.
- Person: an agent reviews and sends the draft. Nothing is sent automatically in the first version.
- Record: one log row per email with category, confidence, queue, whether the draft was edited.
Two of the eight steps use a model. The rest are rules, lookups and a person. That ratio is typical of designs that stay reliable.
How you'll know it works
Before building, measure the current process for two weeks: emails per day, minutes per email, how often emails are routed to the wrong team. After launch, compare the same numbers and add two new ones: the share of low-confidence items (too high means the categories are unclear) and the share of drafts sent without edits. Decide in advance what result would make you switch it off.
Mistakes that sink AI workflows
- Automating an unclear process. If two experienced people would handle the same email differently, the model will be inconsistent too. Agree the rules first.
- Letting the model act on free text. Actions should be driven by validated fields and rules, not by parsing a paragraph the model wrote.
- No low-confidence path. Every model step needs somewhere for uncertain cases to go.
- Too much at once. Automate one queue, prove it, then extend.
- No record. If a run can't be explained afterwards, it can't be trusted or improved.
Key takeaways
- An AI workflow is mostly ordinary automation: trigger, context, rules, actions and records around a small number of model steps.
- Prefer a workflow over an agent whenever you can draw the branches in advance.
- Specify each model step with fixed inputs, a fixed JSON output, allowed values and a low-confidence path.
- Design exception paths and human review deliberately, and log every run.
Exercise: pick one process you know well and fill in the six-part table for it. Mark every step as rule, model or person, and write a specification like classify_support_email for the one model step you think matters most. Keep it: you'll score this process in the next lesson, How to choose which tasks to automate with AI.
Further reading
Written by Abhishek Patoliya, Senior n8n Developer & Automation Architect, Surat, India. Verified n8n Creator.