Most “automation” is one script glued to one trigger. It works until the third thing needs to happen, and then it collapses. The teams that scale past that use a shape instead: a webhook that listens, a middle layer that decides, and a set of actions that fire. Learn the shape once and you can point it at leads, invoices, alerts, or content.
The three stages
- Webhook: the edge. It checks a signature and acknowledges the request. Nothing else.
- Data flow: the middle. Deduplicate, normalise, enrich, and decide. This is where the intelligence lives.
- API funnel: the actions. Write to a database, send a message, create a record, notify a person.
Keep the edge dumb
The most common failure is a webhook that does business logic. The moment the upstream format changes, or a retry fires twice, the whole thing breaks in a way you cannot reproduce. Keep the edge to two jobs: verify the source, and push the payload onto a queue. Every decision moves downstream where you can test it in isolation.
Idempotency is the whole ballgame
Webhooks fire twice. Networks retry. Users double-click. Build the middle stage so that running it twice with the same input produces one outcome. A dedupe key in a small store is enough: before acting, check whether you have already seen this event, and stop if you have.
Design the funnel like a list of facts
- One side-effect per node. Never chain two writes in a single step.
- Log every decision, so a failed run is debuggable from the log alone.
- Fail loudly and safely. An alert now beats a silent drop you find next week.
- Make the retry path the normal path, not an exception you handle later.
A worked example
A lead form posts to the webhook. The edge verifies the source and drops the payload on a queue. The middle stage checks it is not a duplicate, enriches it with company data from an API, and scores it. The funnel then writes the lead to the CRM, sends a Slack message if the score is high, and emails the prospect a confirmation. Every stage can fail on its own without taking the others down.
Why this survives contact with reality
Because each layer has one job, you can swap any of them. Change CRMs? Only the funnel changes. Change the enrichment provider? Only the middle. The edge never needs to know either. That is what makes it reusable across projects instead of a one-off script that rots.
If you want the model lineup that powers the AI stages, start with the 2026 coding engine matrix. For a hands-on build on the same skeleton, the n8n expense tracker walks through a real workflow end to end. And when the whole thing runs from a café, keep the data spend sane with the eSIM vs local SIM math.


1 Comment
Pingback: 2026 Coding Engine Matrix: Multi-Model Production Harness