Free preview lesson
Anatomy of an AI Workflow
Trigger, context, model, action and check: the five parts of every reliable AI automation, and how to spec one before you build.
14 min
Most AI automations that disappoint fail for the same reason: someone dropped an AI step between two apps and hoped for the best. The automations that run quietly for months share a simple anatomy. Once you can see it, you can design, debug and explain any AI workflow, whether it lives in Zapier, Make, n8n or a few lines of code.
The five parts
Every reliable AI workflow has five parts:
- Trigger. The event that starts a run: a form is submitted, an email arrives, a row is added, it's Monday at 7am.
- Context. Everything the model needs to do this particular job well: the incoming data, plus reference material such as your services, tone of voice or policies.
- Model. The AI step itself. Clear instructions and context go in; one specific, well-defined output comes out.
- Action. What happens with that output: a CRM record is updated, a draft is saved, a message is posted to your team.
- Check. How you know it worked, and what happens when it didn't.
Read it as a chain: Trigger → Context → Model → Action → Check.
The check actually wraps around the action. Before acting, you check the model's output (is it valid and sensible?). After acting, you check the result (did the CRM really accept the record?). A workflow without checks doesn't fail less often. It fails silently.
A worked example
Here's the anatomy of a workflow that handles new enquiries from a website form:
| Part | In this workflow |
|---|---|
| Trigger | The website enquiry form is submitted |
| Context | Name, company and message from the form, plus a short description of your services and ideal client |
| Model | Classify the enquiry as hot, warm, cold or spam, give a one-sentence reason and draft a two-sentence reply, returned as JSON |
| Action | Create or update the contact in the CRM, tag it with the category and save the reply as an email draft |
| Check | Is the output valid JSON with an allowed category? Did the CRM accept the record? Anything unexpected goes to a review list |
Without the check, one malformed AI response quietly creates a junk CRM record and nobody finds out for weeks. With it, you get a review item and an alert. Same failure, very different outcome.
Where AI belongs, and where it doesn't
Only the model step should involve AI judgement. Triggers, lookups, arithmetic, date handling, routing on known values and the actions themselves should be plain, deterministic steps that behave the same way every time.
AI shines at language and judgement: reading messy text, classifying, extracting details, summarizing and drafting. It's the wrong tool for anything a filter or formula can do exactly. If "amount is over $500" decides the route, use a filter, not a model.
A helpful picture is the AI sandwich: deterministic steps on both sides, one focused AI step in the middle. Bigger workflows may stack several sandwiches, but each AI step should have exactly one job. When a single prompt tries to classify, extract, decide and write all at once, quality drops and debugging becomes guesswork.
Diagnose problems with the anatomy
When a workflow misbehaves, the anatomy tells you where to look:
| Symptom | Usually weak | Fix |
|---|---|---|
| Output is generic or off-brand | Context | Add examples, tone notes and offer details |
| Output varies wildly between runs | Model step | Narrow the task, define the output format, add examples |
| Downstream errors or junk records | Check (before) | Validate the output before acting |
| Runs fire twice or at the wrong time | Trigger | Add filters and de-duplication |
| Failures go unnoticed | Check (after) | Log every run and alert a named owner |
Write the spec before you build
Before you open any automation tool, write a one-page spec. It takes ten minutes and saves hours of rework:
WORKFLOW: New enquiry triage
GOAL: Every enquiry is categorized and has a draft reply within 5 minutes
TRIGGER: Website enquiry form submitted
CONTEXT: Form fields + "our services" summary + ideal client profile
MODEL STEP: Classify (hot / warm / cold / spam), give a reason, draft a reply.
Output: JSON
ACTIONS: Create or update CRM contact, tag with category, save reply as draft
CHECKS: Before: JSON valid and category allowed
After: CRM confirms the record was saved
FALLBACK: Anything that fails a check goes to the "Needs review" list
OWNER: Sales lead, alerted by email on any failure
Notice the fallback and owner lines. Every workflow must answer two questions up front: what happens when this breaks, and who finds out? If you can't answer them, you're not ready to build.
Build it
- Pick one repetitive task from your week that involves reading or writing text.
- Copy the spec template above and fill in every line for that task.
- For each of the five parts, check that you've written something specific. A blank or vague line is exactly where your build will hurt.
- Look hard at the model step. Can you describe its job in one sentence, with a clearly defined output? If not, split it into two AI steps.
- Save the spec. You'll map the process behind it in the next lesson and build from it in Module 2.
Key takeaways
- Every AI workflow has five parts: trigger, context, model, action and check.
- Checks wrap around the action: validate the output before acting, confirm success afterwards.
- Use AI for the language and judgement step only. Keep everything else deterministic.
- Write a one-page spec, including a fallback and an owner, before you build anything.