User templates
User templates are the highest-priority parser — when one matches with confidence ≥ 80 %, it runs before Ollama and before built-in regex templates. Useful when you want deterministic extraction for a specific carrier, or when you’re running without Ollama and the carrier isn’t in the eight built-in templates.
For most users, the recommended setup (Ollama-first) already gives ~95–100 % accuracy on any airline, including multi-flight bookings. Reach for a user template when you want to override Ollama for a specific carrier you fly very often.
When a user template is worth the effort
Section titled “When a user template is worth the effort”| Situation | Worth it? |
|---|---|
| You’re running Ollama and parsing works fine | Probably not — Ollama already covers any airline well |
| You fly LH/LX/OS/SN/FR/U2/EW/W6 and have Ollama disabled | No — built-in regex template already covers single-leg bookings |
| Ollama is disabled and you fly a non-built-in carrier 5+ times a year | Yes — fills the gap until you turn Ollama back on |
| You want extraction to be deterministic for a single carrier (e.g. for a corporate workflow) | Yes — user template wins over both Ollama and built-in |
| You fly a carrier once a year | Probably not — Ollama covers it; manual entry covers it without |
Built-in templates are also a good baseline if you decide later you’d rather contribute your template upstream than keep it private — see Contributing.
Recording a template
Section titled “Recording a template”Admin → Parser Templates → Record new (admin-only, since templates are instance-wide).
- Provide a sample email. Either paste the body or upload an
.emlfile. The fuller and more representative, the better — pick a typical confirmation, not an edge case. - Mark the airline. IATA code (e.g.
KLfor KLM) plus the name. This is what you’ll see on flights this template parses. - Mark the detection signals.
- Sender domain — pick from the auto-detected list, or type it.
- Subject pattern — the parser auto-suggests a regex from the subject line of your sample; you can tighten it.
- HTML fingerprint — a string that’s reliably present in the HTML body. Often the airline’s main domain name.
- Mark the field locations. The interactive editor highlights candidate fields and asks you to confirm:
- Flight number → click on it in the email
- Date → click on it
- Departure / arrival airport → click on each
- Times → click on each
- PNR / booking reference → click on it
- Passenger name → click on it
- Save and test. The right side of the editor shows a live preview of the parser running against your sample; everything should highlight correctly. If a field isn’t picking up reliably, refine the rule (the editor lets you switch from text-match to regex).
- Verify against a second sample. Paste another email from the same airline (different flight, different date) into the test pane. The parser should pull all fields correctly.
Save. From now on, every email from that sender will parse through your template automatically.
How user templates rank in the parser pipeline
Section titled “How user templates rank in the parser pipeline”When detection runs (Ollama-first when configured):
1. User template (confidence ≥ 80 %) → highest priority2. Ollama LLM → recommended primary parser3. Built-in regex templates → fallback for the 8 supported carriers4. Generic regex extractor → last-resortUser template wins over everything else when its confidence is high enough. Below the 80 % threshold, the parser moves on to Ollama (or, if Ollama is disabled, to the built-in regex templates). This means a user template is the right choice when you want deterministic, override-Ollama extraction for a specific carrier — e.g. a corporate workflow that needs predictable field mapping.
Editing or removing a template
Section titled “Editing or removing a template”Admin → Parser Templates lists every template you’ve recorded. For each:
- View the matching rules and field-extraction patterns
- Edit any rule — useful when the airline tweaks their email format
- Delete to remove the template (the parser falls back to Ollama or whatever else applies)
- Statistics — how many flights this template has parsed, average confidence score
What gets stored
Section titled “What gets stored”In the database, each user template is a row in the ParserTemplate
table:
id (uuid)airlineIata (e.g. "KL")airlineName (e.g. "KLM")fromDomains (text[] — sender domains that match)subjectRegex (regex string)fieldRules (JSON — per-field extraction rules)createdAt (timestamp)ownerId (which admin recorded it)The reference example email is not stored by default — once the template’s rules are extracted, the example is discarded for privacy. If you’d rather keep the sample email for reference, the record-new screen has an opt-in toggle.
Sharing templates
Section titled “Sharing templates”Templates aren’t shareable between TravStats instances out of the
box — there’s no export/import yet for the ParserTemplate table.
If you’ve recorded a useful template and want to contribute it
upstream as a built-in:
- Fork github.com/Abrechen2/TravStats
- Add a JSON file to
backend/src/services/parsers/templates/airlines/ - Update
backend/src/services/parsers/templates/detector.tswith the detection signals - Add a test fixture to
backend/src/services/parsers/__tests__/ - PR
The detection rules in your private template translate directly to the built-in format. Most contributions are accepted within a release cycle.
Limitations
Section titled “Limitations”User templates handle the common case (one airline, one sender domain, one fairly predictable email layout). They struggle with:
- Codeshare confirmations where the operating carrier email is branded differently from the marketing carrier — fall back to Ollama, or let the flight-lookup API resolve the codeshare
- Multi-airline emails (consolidator bookings with multiple legs operated by different carriers) — Ollama handles these better
- Marketing emails that mention a flight number but aren’t a booking confirmation — usually filtered out by the subject regex, but if one slips through you’ll see it on the review screen and can delete it
For everything else, user templates plus the eight built-ins cover ~99% of European personal travel. Outside Europe, your mileage varies — but the Ollama fallback at ~95% is still better than typing.