Quick overview
This workflow receives enquiries via a webhook, deduplicates repeated submissions using an idempotency key stored in an n8n Data Table, and processes accepted enquiries with keyword-based classification and Telegram notifications, automatically retrying failed processing on a schedule.
How it works
- Receives an enquiry via a POST webhook and loads configurable settings like required fields, deduplication window, and retry limits.
- Validates the request body and immediately replies with HTTP 422 if required fields are missing.
- Builds an idempotency key from the Idempotency-Key/X-Request-Id headers or a SHA-256 hash of a normalized request body, then checks an n8n Data Table for a recent matching record.
- Responds with HTTP 200 for duplicates, otherwise logs the enquiry as “received” in the Data Table and returns HTTP 202 accepted (with a race-condition guard that keeps only the earliest copy).
- Loads the saved payload, classifies it into priority and category based on configured keywords, and sends a formatted message to Telegram.
- Marks the Data Table row as “done” on success, or records the error, increments attempt count, and sets the row to “failed” or “dead” (with a Telegram alert) when max retries is reached.
- Runs every 15 minutes to find “received”/“failed” rows that have waited long enough and retries the processing path until they succeed or become dead letters.
Setup
- Create (or choose) an n8n Data Table and set its name in Config, ensuring it includes fields for idempotencyKey, keySource, status, attempts, payload, lastError, category, priority, and processedAt.
- Add a Telegram credential and set the target Telegram chat ID in Config for both the main notification and dead-letter alert.
- Configure required fields, idempotency header names, keyword lists, dedupe window, retry interval, and max attempts in the Config step.
- Activate the workflow, copy the production webhook URL for the “enquiry-intake” path, and configure your form/app to POST enquiries to it (optionally sending an Idempotency-Key header).