Human-in-the-Loop AI Drafts in n8n Without the Mess: One Pending Draft per Customer, Stale Expiry and Out-of-Order Webhooks (2026)
Description and use
Implementing deterministic draft keys, a partial unique index, version checks, and automatic expiration prevents duplicate drafts, overwriting of newer data, and sending of stale approvals in n8n.
Problem
Multiple drafts, duplicate webhooks, out-of-order events, and stale approvals cause incorrect or repeated AI-generated content to be sent to customers.
Outcome
The pattern ensures deterministic draft keys, single pending drafts, idempotent webhook handling, version-aware updates, and automatic expiration, preventing duplicate sends and stale approvals.
Workflow
- 1. Webhook intake builds draft_key, event_key, and version.
- 2. Postgres inserts into seen_events to drop duplicate deliveries.
- 3. Postgres upserts into draft_queue with a partial unique index on draft_key where status='pending'; skips events with lower or equal source_version.
- 4. LLM writes draft only for new or newer events.
- 5. Upsert bumps revision and notifies reviewer once per key.
- 6. Scheduled trigger expires stale drafts hourly.
Evidence
give every draft a deterministic draft_key (hash of the customer or record plus the action type), keep at most one pending draft per key with a partial unique index
Postgres drops duplicate deliveries via seen_events
Store source_version (event updated_at), skip events with a lower or equal version
expires_at, hourly sweep sets expired, never auto-sends
- Record date: 2026-11-03T03:28:58.035Z