DEV Community

Cover image for Timesheet Guardian: an n8n workflow that checks time tracking against German working-time law
Daniele Michelin
Daniele Michelin

Posted on Originally published at daniele-michelin.com

Timesheet Guardian: an n8n workflow that checks time tracking against German working-time law

Try the Timesheet Guardian → The page checks an entry in your browser and draws a live chart. The real forms are at mikweb.eu/form/zeitwaechter (hours) and /zeitwaechter-abwesenheit (absences). All data is demo data and the people are made up (Musterbüro GmbH).

Why bother

Since the Federal Labour Court ruling of 13 September 2022 (1 ABR 22/21), German employers have to record working time. A spreadsheet often does the job. What it does not do is tell you that someone worked 11 hours yesterday without a proper break and starts again at 06:00 today. That usually surfaces when someone reads the list at month end. I wanted the violation to trigger a card and a message the same evening, with nothing more exotic than n8n, Nextcloud and a CSV.

Legal status: the recording duty has applied since 2022. A reform of the Working Hours Act (a draft from the federal labour ministry) had not been passed as far as I knew in June 2026. Check where it stands today. This is a technical example and not legal advice.

What the workflow does

  1. Two n8n forms: hours (person, date, start, end, break, project, activity) and absence (person, from, to, kind: vacation, sick leave or flextime off).
  2. Validation of the input (format, times, date), then saving to zeiten.csv in Nextcloud over WebDAV.
  3. ArbZG check over all rows, then a comparison with the state before the entry: only new violations trigger anything.
  4. On a new violation: a card in Nextcloud Deck and a message in Talk.
  5. Absences become CalDAV events. A second check finds hours logged on a day of absence.
  6. Friday 15:00: a weekly report as Markdown and as an SVG dashboard in Nextcloud, plus Talk.
  7. Monday: the demo data is reset.

The rules

  • Section 3: at most 10 hours a day, 8 hours on average.
  • Section 4: a 30-minute break after more than 6 hours, 45 minutes after more than 9.
  • Section 5: 11 hours of uninterrupted rest between two working days.
  • Section 9: Sunday work.
  • Hint: more than 48 hours in a week. A hint, not a violation: the law works with averages.

All of it is deterministic code (core.js, over 100 checks pass in node test_core.js). The AI (IONOS gpt-oss-120b) writes only three sentences of the weekly report and sees no names, only numbers. Whether someone broke the law is never decided by a language model.

Concurrent writes: ETag and If-Match

Two people submit at the same time, both read the CSV, both write it back: one entry is gone. So, optimistic locking over WebDAV: GET returns the file with its ETag, and the PUT sends If-Match: <ETag>. If the file changed in between, Nextcloud answers 412 Precondition Failed. The workflow then reads again and retries, up to three times. After the third failure it says so, instead of overwriting something silently.

What I learned on n8n 2.46.6

  1. Do not set "Respond When" to "Using Respond to Webhook". With Form Trigger v2.5 and the n8n Form node you get "Respond to Webhook not supported in workflows initiated by Form Trigger" or "No Respond to Webhook node found". Leave the default: the Form node gives the response.
  2. The Form node's Completion operation with "Show Text" accepts full HTML. The response can be an entire page, including an inline SVG chart. Mechanically: the form POST returns JSON with formWaitingUrl, the browser goes to /form-waiting/<id>, and the page appears there.
  3. HTTP Request with full response and text: the content is in data, not body. My res.body was undefined and the CSV was rewritten with a single row. Since then there is a data-loss guard: if parsing yields zero rows although the file is not empty, the run stops instead of writing.
  4. Which of the five triggers fired? Check $('Node').isExecuted; that lets one workflow serve all of them.
  5. The Code node has no URL class. Use regular expressions.
  6. CSV injection. Cells starting with =, +, - or @ get a leading '. Otherwise Excel runs a formula hidden in a project name.
  7. Nextcloud WebDAV: If-Match with the ETag from the GET works, and a stale ETag gives 412. That is exactly what you need.

Try it and download it

Download the workflow JSON → Import it, add your own Nextcloud and IONOS credentials, and adjust the Nextcloud path, Deck board and Talk room. No secrets are in the JSON. The AI sentences are optional: without the credential the report keeps the numbers.

Limits

This is a demo setup, not a production timekeeping system. The data is made up. No works council, no collective agreements, no exceptions under section 7 or sector rules (care, hospitality, transport), and different rules apply to minors, pregnant employees and drivers. The thresholds follow the text of the law but do not replace a review by someone who knows your company. What the reform changes is not covered here: please read up on the current state.

Related: the Rubber Stamp Test shows why "a human looks at it" is not enough on its own. Here the code does the checking, and the human only sees the cases that matter.


Originally published at daniele-michelin.com. More guides, free checks (SPF, TLS, headers) and an error-message lexicon: daniele-michelin.com/en/.

Top comments (0)