# Guard AI agent Postgres writes using OpenAI, FirstHelm, and Slack approvals

> Quick overview Your agent can propose a SQL write; this workflow makes sure it never runs one it shouldn't. A deterministic allowlist check, a FirstHelm policy gate and a human approval step sit between the model and Postgres. Nothing destructive executes unlogged. How it works 1. Receives a POST request via webhook containing an instruction, requester, and environment. 2. Logs the incoming write request to FirstHelm for audit purposes. 3. Uses OpenAI to generate a JSON response containing one proposed Postgres SQL write statement and a short rationale. 4. Deterministically validates the SQL against safety rules (single statement, no DDL/privilege changes, scoped UPDATE/DELETE with WHERE, and allowed tables) and immediately refuses and audits failures. 5. Sends the validated SQL to FirstHelm’s policy gate to return a verdict of allowed, needsapproval, or blocked. 6. If allowed, executes the SQL in Postgres, logs execution details (including rows affected) to FirstHelm, and returns an e

- **Domain**: `n8n-workflow-22054.n8n.io`
- **Provider**: n8n.io (https://n8n.io)
- **Kind**: workflow
- **Live-responds (last probe)**: None
- **Signed card**: False
- **Streaming**: False
- **Quality score**: 40%

## URLs
- Agent card: https://n8n.io/workflows/22054
- Page (HTML): https://agenstry.com/agents/n8n-workflow-22054.n8n.io
- Documentation: https://n8n.io/workflows/22054
