Why Putting an LLM in Your Webhook Hot Path Is a Mistake (And How I Built a Zero-PII Self-Healing Gateway in .NET 9)
Modern SaaS backends rely on dozens of external webhook producers—Workday, Stripe, Razorpay, HubSpot, Shopify. Transport-level retries (502 / 504 exponential backoff) are a solved problem.
Silent payload contract drift is not.
Picture a Tuesday afternoon in production. An upstream vendor ships a minor v2 update and quietly renames "email" to "candidate_email" in their JSON payload:
{ "candidate_id": "WD-9042", - "email": "priya.sharma@enterprise.io", // What your backend expects + "candidate_email": "priya.sharma@enterprise.io", // What the vendor now sends "job_code": "STAFF-NET-01" } What happens next in most production stacks?
- Your ingestion endpoint rejects the payload with
400 Bad Requestor throws aNullReferenceException. - Existing webhook gateways (Hookdeck, Svix, Convoy) dutifully retry the exact same broken payload until it expires in a Dead-Letter Queue (DLQ).
- Worse: if you store raw failed webhooks in gateway logs—or pipe raw payloads straight into an LLM to "auto-fix" them—you just leaked customer PII (names, emails, payment metadata) across logs and third-party model APIs.
To solve both problems cleanly, I built VigilHook—a Zero-PII, self-healing webhook gateway and DLQ observability console powered by .NET 9, Angular 19, and Neon PostgreSQL.
- Live Interactive Console: vigilhook.vercel.app (Runs on Render's free tier—give it ~50s to wake up on the first click)
- Source Code & Blueprint: github.com/Abhisheknik/VigilHook
Why Naive "AI Webhook Proxies" Fail in Production
When developers first think about combining LLMs with webhook gateways, the instinctive design is to put an LLM call inline on failed requests. In production, that breaks down across three dimensions:
- Latency & Upstream Timeouts: Webhook producers enforce tight
3s–10stimeouts. Waiting on LLM inference synchronously causes cascading retries and duplicate events. - Recurring Token Cost: Paying for LLM tokens on every drifted webhook scales linearly with traffic spikes.
- PII Compliance Violations: Customer emails, phone numbers, and tokens should never sit in plaintext gateway logs or leave your security boundary unmasked.
The 4 Architectural Pillars of VigilHook
Instead of putting AI in the hot path, VigilHook uses a four-stage architecture where AI learns once, C# verifies deterministically, and customer PII never leaves the memory boundary.
1. Edge Ingress & Zero-PII Boundary
Every incoming POST /api/webhooks/{source} first passes an X-Idempotency-Key check to block duplicate vendor retries.
Next, the payload splits into two isolated paths in memory before touching the database:
- Audit & AI Path (
PiiSanitizer): Traverses theJsonNodetree and masks sensitive fields (email,phone,name, tokens) into structural markers like"[REDACTED_EMAIL]"and"[REDACTED_PII]". - Ephemeral Replay Vault (
IDataProtectionProvider): Encrypts the intact raw payload using ASP.NET Core Data Protection (AES-256) solely so it can be replayed losslessly after repair.
2. Bounded System.Threading.Channels Quarantine
When a payload misses a required contract field (e.g., "email" is missing), VigilHook does not make the vendor wait for an LLM:
- It persists the redacted event as
Failed_SchemaDrift. - It returns
202 Acceptedimmediately so the producer never times out. - It pushes
WebhookEvent.Idinto a boundedSystem.Threading.Channels.Channel<Guid>processed asynchronously by aBackgroundService(DlqWorker).
// Decoupling edge ingestion (202 Accepted) from background AI schema analysis await _dlqChannel.Writer.WriteAsync(webhookEvent.Id, cancellationToken); return Accepted(new { eventId = webhookEvent.Id, status = "Failed_SchemaDrift" }); 3. Zero-PII AI Diagnosis + Deterministic C# Guardrails
DlqWorker sends only the PII-redacted JSON structure to a pluggable ILlmService (supporting OpenRouter, Groq, or air-gapped local Ollama).
More importantly, VigilHook never trusts raw LLM output blindly:
- A deterministic C#
JsonDocumentverifier confirms that every source key proposed by the LLM actually exists in the incoming payload, and every target key exists inIntegrationSchema.RequiredFields. - Hallucinated field names are rejected automatically before surfacing a
RepairProposalto the operator.
4. One-Click Rule Promotion (< 1 ms, 0 LLM Tokens)
In the Angular 19 (Signals) operator console, an engineer inspects the side-by-side Split Diff (seeing only [REDACTED_EMAIL]), confirms the candidate_email → email mapping, and clicks Approve & Replay ↗.
Behind the scenes, VigilHook executes four atomic steps:
- Decrypts the raw payload from
EncryptedRawPayloadin memory. - Applies the JSON key patch and forwards the intact payload (
200 OK) to your internal backendTargetUrl. - Hard-purges the encrypted vault (
EncryptedRawPayload = null)—zero raw customer data remains at rest. - Promotes
{"candidate_email": "email"}intoIntegrationSchema.MappingRulesJson.
From that millisecond onward, every future drifted webhook from that vendor auto-heals deterministically in < 1 ms with 0 LLM tokens.
Try the Live Sandbox in 60 Seconds
You don't need to clone anything to test the full lifecycle:
- Open vigilhook.vercel.app and wait for the top status indicator to connect.
- Click
+ Simulate Drift(which sends a driftedWorkdaypayload with"candidate_email"instead of"email"). - Open the quarantined item in DLQ Inspector—notice how PII is masked as
"[REDACTED_EMAIL]"while the AI proposescandidate_email → email. - Click
Approve & Replay ↗with Promote mapping rule checked. - Click
+ Simulate Driftone more time—watch it bypass the DLQ completely and land in Traffic & Audit Log as200 OK · Auto-Healed · 0 tokens.
Tech Stack Summary
- Backend: .NET 9 Web API, C# 13,
System.Threading.Channels, ASP.NET Core Data Protection (AES-256) - Database: EF Core 9 with dual-provider support (zero-config SQLite locally, Neon Serverless PostgreSQL via
Npgsqlin production) - Frontend: Angular 19 (Standalone Components, Signals, RxJS)
- AI Layer: Pluggable
ILlmService(OpenRouter, Groq, or local Ollama)
If you're building webhook infrastructure or wrestling with third-party API drift in .NET, check out the repo at github.com/Abhisheknik/VigilHook—I'd love your feedback on the channel worker pattern and Zero-PII boundary!