Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Human-in-the-Loop AI Drafts in n8n Without the Mess: One Pending Draft per Customer, Stale Expiry and Out-of-Order Webhooks (2026)

Описание и применение

Внедрение ключей драфтов, уникального индекса, проверки версии и автоматического истечения сроков позволяет избежать дублирования, перезаписи старых данных и отправки устаревших сообщений в n8n.

Задача

Multiple drafts, duplicate webhooks, out-of-order events, and stale approvals cause incorrect or repeated AI-generated content to be sent to customers.

Результат

The pattern ensures deterministic draft keys, single pending drafts, idempotent webhook handling, version-aware updates, and automatic expiration, preventing duplicate sends and stale approvals.

Рабочий процесс

  • 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.

Доказательства

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

Источник

  • Дата записи: 2026-11-03T03:28:58.035Z