Authorize AI agent actions with Postgres, Slack, and PagerDuty alerts

Go to Workflow
0 views
Built by Oneclick AI Squad Oneclick AI Squad
Created on October 24, 2026

Description

Quick overview
This workflow exposes a webhook-based policy-as-code authorization service that evaluates AI agent action requests against prioritized rules stored in Postgres, logs every decision for auditing, and optionally sends Slack and PagerDuty alerts for high-risk denials or approval requirements.

How it works
Receives a POST request on the /policy-evaluate webhook (or runs manually/on a schedule) to start an authorization evaluation.
Ensures the required Postgres tables exist for policies, decisions, and run tracking.
Loads enabled policies (ordered by priority) and 24-hour decision statistics from Postgres, then merges them with embedded fallback policies and configuration.
Normalizes the incoming request, calculates a risk score, and evaluates policies in priority order to return the first matching effect (allow, deny, or require_approval).
Writes the decision and a run summary to Postgres for auditability.
If the decision is deny or require_approval and the risk score exceeds the configured threshold, sends a notification to Slack and optionally triggers PagerDuty for severe denials.
Responds to the webhook caller with the final decision payload including the matched policy, reason, and risk score.

Setup
Configure a Postgres credential and ensure the target database is reachable from n8n.
Update the embedded CONFIG values (especially the default effect, embedded policies, risk thresholds, Slack incoming webhook URL, and optional PagerDuty routing key).
Activate the workflow and copy the webhook URL for /policy-evaluate into the AI agent/tooling that needs authorization checks.
(Optional) Seed the agent_policies table with your own enabled policies to override the embedded fallback rules.

This workflow was created by Oneclick AI Squad and shared publicly on the n8n community template library. n8nFind indexes it for discovery — the workflow remains the property of its original creator.

Nodes Used (3)

Code
n8n-nodes-base.code
HTTP Request
n8n-nodes-base.httpRequest
Postgres
n8n-nodes-base.postgres