Running the Bot End to End
Why This Matters
Before you test parts in isolation, see the whole thing work. Running the bot end to end on real sample emails shows you what “booked”, “needs review” and “failed” look like, and what the logs tell an operator.
Start the fake ERP
The real ERP is not available in a course, so the project has fake_erp.py: a tiny web server with the same kind of order API (POST /orders returns 201 and an erp_id, a duplicate order returns 409). In a first terminal:
python fake_erp.py
Process the three samples
In a second terminal (with the virtual environment active):
python -m intake samples/order-1.eml samples/order-2.eml samples/order-3.eml --today 2026-12-01
Read it like an operator:
| Sample | Result | Why |
|---|---|---|
order-1.eml | booked as ERP-1001 | Everything matches the catalogue; total 2848.80 |
order-2.eml | needs review | The supplier raised the price of the daypack by 10%; a person must agree before it is booked |
order-3.eml | failed | The email has no price and no date (“same price as last time”, “asap”); nothing is guessed, nothing is booked |
The exit code is 1 because one message failed. Schedulers and CI use exit codes to notice that something needs attention.
Why --today?
The rules check that the delivery date is not in the past. Without --today, the result depends on the day you run it: the same email is booked today and needs_review next month. Passing the date in makes runs reproducible, and in lesson 8, Testing Business Rules: Boundaries and Breaking It on Purpose you will see the same idea in the tests.
Exercise
- Run the bot as shown. Do you get the same three results?
- Run it again without restarting the fake ERP. What happens to order 1, and why? (Hint: the ERP refuses duplicates.)
- Change the price in
samples/order-2.llm.jsonto65.00and run order 2 again. Restore it withgit restore samples/order-2.llm.json.
Key Takeaways
- Run the automation end to end before testing parts in isolation.
- Every message gets one clear result, and the log says why.
- Exit codes let schedulers and CI notice failures.
- Pass “today” in to make date rules reproducible.
