Skip to main content

From a Process to Code

Why This Matters

Most failed automations fail before the first line of code: nobody wrote down what the process really is, which decisions it contains, and what should happen when something is unusual. AI makes this worse, because it happily writes code for a process nobody understood. Map the process first.

The order intake process, on paper

At BuitenGear, an outdoor retailer, the purchasing team receives about forty order confirmations from suppliers per week. Today someone reads each email and types the order into the ERP. That takes about six hours a week, and typing errors cause wrong stock and wrong invoices.

Write the process as steps and decisions:

#StepWho / what todayAutomated by
1Read the emailPersonsources.py: read the .eml file
2Find supplier, order number, date, lines and pricesPersonextract.py: an LLM turns free text into fields
3Check the order against the catalogue and the rulesPerson, from memoryvalidate.py: explicit rules
4Decision: book or ask?Personpipeline.py: no issues → book, issues → human
5Type the order into the ERPPersonerp.py: the ERP’s order API

Three outcomes, never a silent one

Every message ends in exactly one of three statuses (see intake/pipeline.py):

StatusWhenWhat happens
bookedExtraction worked and no rule found an issueThe order is in the ERP, with its ERP id logged
needs_reviewExtraction worked, but a rule found an issueNothing is booked; a person gets the order and the list of issues
failedThe LLM answer was unusable, or the ERP refusedNothing is booked; the error is logged

The most important design decision is in that table: when in doubt, a human decides. An automation that books a wrong order silently is worse than no automation.

Where the risks are

For each step, ask what can go wrong and how you would notice:

Use AI to challenge your map

Here is a process map for automating supplier order confirmations: <paste the table>.
Which steps, decisions or failure situations am I missing?
Answer as a table: situation, what should happen, how we would notice.

Exercise

  1. Take the task you chose in lesson 1, Why Python, and What Changes with AI and write it as a table of steps and decisions, like the one above.
  2. For each step, decide: rule, LLM, integration, or human?
  3. Define your three outcomes, and what a person receives for each.
  4. Ask an AI assistant to challenge your map. Add the situations that are real; reject the rest.

Key Takeaways

  • Map steps, decisions and outcomes before writing or generating code.
  • Every message gets exactly one status: booked, needs review or failed.
  • When in doubt, a human decides; nothing is booked silently.
  • List the risks per step and how you would notice them.