Quick overview
This workflow matches two transaction datasets (for example, bank transactions and ledger entries) using fuzzy scoring plus optional OpenAI-compatible embeddings, stores matches and review tasks in PostgreSQL, and sends uncertain matches to Slack for human approval via signed webhook links.
How it works
- Runs on a manual trigger, a 4-hour schedule, or a POST webhook to start a matching run.
- Creates/updates the required PostgreSQL tables, loads prior match history, rejections, learned counterparty aliases, pending reviews, and the approval signing secret.
- Fetches left and right records from two configured HTTP APIs, normalizes amounts to a base currency, de-duplicates by ID, and aborts the run as failed if either source response is invalid.
- Generates candidate pairs with blocking (amount/date/reference/name tokens), calculates fuzzy similarity features, and selects which records need embeddings when fuzzy matching is not confident.
- Looks up embeddings in a PostgreSQL cache, calls an OpenAI-compatible /embeddings endpoint for missing vectors, and fuses semantic similarity into the final score without allowing it to override numeric mismatches.
- Assigns one-to-one matches, auto-saves clear matches to PostgreSQL, queues ambiguous items for review with top candidates and reasons, and posts review requests to Slack with expiring HMAC-signed links.
- Serves a GET review page and a POST decision endpoint that re-validates the signature, applies the approval or rejection atomically in PostgreSQL, updates alias learning/rejection rules, and returns an HTML confirmation page.
Setup
- Add a PostgreSQL credential (PostgreSQL 13+ recommended for gen_random_uuid()) and ensure the workflow can create tables in the target database.
- Update the config in the workflow’s configuration code with your left/right source API URLs, auth headers/tokens, query parameters, and field mappings.
- Configure Slack incoming webhook URL for notifications and make your n8n instance publicly reachable, then set approval.publicBaseUrl to your public webhook base so signed review links resolve.
- Provide an OpenAI-compatible embeddings endpoint URL, API key, model, and dimensions (or set embeddings.enabled to false to run fuzzy-only).
- Activate the workflow to generate the production webhook URLs for tm-review and tm-decide, and configure the run webhook path (transaction-matching) in your calling system if using webhook-based runs.