Anatomy of an automation
The seven parts every production workflow needs, and one lead traced through all of them.
Includes an interactive demo: Payload inspector
In one sentence
An automation is a trigger followed by a chain of steps that move and change data between your tools, with rules deciding the path and a log recording what happened. AI is one kind of step: the one you use when a rule can’t do the job, like reading a messy email.
I build these in n8n, Make or Zapier, depending on the team’s stack, with Claude or OpenAI models for the AI steps. The pattern below is the same in all of them.
Watch the data change
The clearest way to understand a workflow is to follow one record through it. Step through the stages and watch the payload: new fields are highlighted as each step adds them.
- Trigger: A web form is submitted. A webhook hands the raw payload to the workflow.
- Validate: Trim and normalise fields, check the email, and stop early if anything required is missing.
- Deduplicate: Look the contact up in the CRM so the same person never becomes two leads.
- AI extract: An AI step reads the free text and returns structured fields that match a fixed schema.
- Route: Plain rules, not the model, decide what happens next. Low confidence goes to a person.
- Act: Each action is idempotent: running the same event twice can never create two deals or two emails.
- Log: Every run writes one record. This is what dashboards, alerts and audits are built on.
The seven parts
| Part | What it does | What goes wrong without it |
|---|---|---|
| Trigger | Starts the run: a webhook, a new row, an email, a schedule. | Polling every minute, missed events, runaway costs. |
| Validate | Normalises and checks inputs; fails fast on bad data. | Garbage flows into the CRM and nobody trusts it. |
| Deduplicate | Matches against existing records. | The same customer gets three welcome emails. |
| AI step | Turns unstructured text into structured fields. | Someone reads every message by hand. |
| Route | Deterministic rules pick the path. | The model makes business decisions nobody can audit. |
| Act | Writes to your tools, idempotently. | Retries create duplicates. |
| Log | One record per run, with status and timing. | When it breaks, nobody knows when or why. |
AI is a step, not the system
The most common mistake is letting a model run the whole process. In production I keep the model on a short leash: it extracts or drafts, and returns JSON that must match a schema. Rules decide what to do with it.
{
"need": "quote automation",
"budget_usd": 8000, // number, not "~8k"
"timeline_days": 30,
"score": 86, // 0-100, from a written rubric
"confidence": 0.93 // below 0.75 goes to a person
}When things fail
Every external call can fail: an API times out, a token expires, a rate limit hits. Good workflows plan for it.
- Retry with backoffWait 2s, 4s, 8s before giving up, for errors that are temporary.
- Make actions idempotentUse a key per event so a retry can’t create a second deal or email.
- Dead-letter queueAnything that still fails lands in a list a person reviews, with the full payload.
- Alert on patternsOne failure is noise. Five in an hour posts to Slack.
Production checklist
- Every input validated, every required field checked
- AI output parsed against a schema
- Business rules outside the model, written down
- Retries with backoff and idempotency keys
- A review queue for low confidence and failures
- One log record per run, and a dashboard on top
- Secrets in the platform’s credential store, never in the workflow
- A short runbook: what to do when it alerts