Step 1: Ignore the robots
Pebblebrook Vets gets its email and website messages through a webhook: each new message arrives as an event,
and an automation answers it. You will build that automation in automation.yaml. There is no code to write.
Click Run first. The starting automation sends a reply to every message. Look at the top of the scorecard: it answered a newsletter, a bounce message and an out-of-office autoresponder. The autoresponder answered back, and the bot answered that too: a reply loop, stopped only by the lab after three rounds.
Machines mark their mail. Autoresponders and notifications set an Auto-Submitted header (some use
X-Autoreply), mailing lists set List-Unsubscribe, and bounces come from senders like mailer-daemon. People
can write anything in a subject line, so a rule based on the subject can catch a real customer.
Do this in automation.yaml, under ignore::
- Add one rule per line:
- header: Auto-Submitted,- sender_contains: no-reply, and so on. The three kinds areheader:(the message has that header),sender_contains:andsubject_contains:. Case is ignored. - Click Run. The four machine messages should show
ignore, and no one else's. python3 run_automation.py --event 19shows one machine message in full.
The check also tries your rules on three machine messages and three people's messages that are not in the inbox.
automation.yaml, the file you edit26 lines
# automation.yaml: what happens when the clinic's inbox webhook delivers a message.
# Placeholders: {message} the sender, subject and text {clinic} the clinic's facts (clinic.md)
# {classify} the classify step's JSON, and {classify.category}, {classify.urgent} its fields
# Models: small = Llama 3.1 8B (cheap) large = Llama 3.3 70B
ignore:
# TODO (Step 1): rules for messages sent by machines: auto-replies, bounces, newsletters, notifications.
classify:
model: small
prompt: |
What is this message about? Give it a category and say if it is urgent.
{message}
Reply with only JSON: {"category": "...", "urgent": true or false}
draft:
model: small
prompt: |
Write a friendly reply to this message from a vet clinic.
{message}
routes:
- action: sendautomation.pyclinic.mdevents.jsonlrun_automation.py