Scheduled count check: missing, extra and mismatched orders in one daily email

This is the tested version I offered in the Tips topic. Set to run every morning at 07:00, it reads yesterday’s orders at a source and a destination, matches them on order_id, and sends one email listing missing, extra and mismatched rows. It sends on clean days too.

I wrote “orders and invoices” there; this version compares orders only.

What arrives (mixed test day):

Subject: Count check 2026-10-22: 2 missing, 2 extra, 2 different

Daily count check for 2026-10-22.

Source: 10 orders. Destination: 10 rows (read up to 02:00 today).

Missing at the destination (2): 2004, 2007

Only at the destination (2): 2005 (second copy), 2999 (not in the source)

Different (2):

- 2003: amount 245 -> 254

- 2006: status refunded -> paid

This message is sent every day, also when everything matches. If it does not arrive, the check itself has stopped.

Why Always Output Data is on

Without it the check itself can go quiet. Two control copies:

  • Off on Compare Datasets, clean day: the execution succeeded, the Code node never ran, no email.
  • Off on the two reads, empty day: the execution succeeded, no email.

How it decides

  • Source: orders created yesterday. Destination: rows written from yesterday 00:00 to 02:00 today, minus rows for other days’ orders. So order 2010 (written 00:03) counts as present and order 2007 (written 02:30) as missing.
  • Compare Datasets uses “Include Both Versions” and skips id, createdAt, updatedAt, written_at.
  • The Code node reads outputs 0, 2 and 3 (In A only, Different, In B only) by index and skips the empty item Always Output Data adds when nothing is missing.

Extra rows and mismatched fields came up in replies from @runlookout and @Mahdi_Eqbal.

Setup

  1. Create two Data Tables. The workflow finds them by name:
    • count_check_source: order_id (string), order_created_at (date), amount (number), status (string)
    • count_check_destination: the same, plus written_at (date)
  2. Paste the JSON below into an empty workflow.
  3. In “Send the daily message”, pick your SMTP credential and set the two example.test addresses.
  4. The JSON sets no time zone, so 07:00 and “yesterday” follow your instance default (tested with Europe/Istanbul). The 2-hour margin is destination_to in “Set the window” (the “02:00” in the message text is set in the Code node).
  5. Publish.

For your own systems, swap the two Read nodes (I have only run it on Data Tables). Keep Always Output Data on, keep order_id and order_created_at, and add the columns your destination fills in by itself to “Fields to Skip Comparing”.

Tests

12/12 checks passed on n8n 2.43.6 (self-hosted, Docker, synthetic data, local Mailpit), on my instance and on a fresh one after pasting this JSON. The Schedule Trigger started every run itself (one-off cron a few seconds ahead). I also moved the daily rule a few minutes ahead once: it fired at the set minute and the email arrived.

Scenarios: mixed day, clean day, only an extra row, both sides empty, destination empty, and the two controls.

1 Like

Update for n8n 3.0: Always Output Data now adds its empty item only when every output of Compare Datasets is empty, so the JSON above sends no email on a day with nothing missing, clean days included. The updated JSON joins the four Compare outputs in a Merge node (Wait for every output) before the Code node. 12 of 12 checks passed on self-hosted n8n 2.43.6 and on the 3.0.1 pre-release: GitHub - krafera/n8n-daily-count-check: n8n workflow: daily email listing missing, extra and mismatched orders between a source and a destination · GitHub

Nice implementation. I particularly like the use of Always Output Data to ensure the workflow sends a report even on clean days or when either source is empty.

The distinction between missing, extra, and mismatched records makes the reconciliation process much more useful than a simple count comparison.

One important detail is that the daily confirmation email also acts as a health signal — if it stops arriving, the team knows the check may need attention.

1 Like