Urgent.News

What's breaking now, across thousands of outlets.

Tech

n8n Guardian Gates: How Approval Workflows Prevent Agents from Sending the Wrong Invoice

An agent that drafts 60 client emails a month will eventually send one with the wrong amount. You cannot unsend an email to a customer. The standard workaround is to check every draft by hand, which turns a 10-minute automation into a 3-hour review session. The better pattern is a policy gate that separates draft generation from irreversible send actions. Let the agent read data, sort records,…

Small offices often draft 60 client emails per month, but inevitably one email contains the wrong amount. Undoing an email sent to a customer is impossible. Instead of manually checking every draft, a better solution is to implement a policy gate that separates draft generation from irreversible send actions. This ensures that the agent can read data, sort records, and compose text, while any action that affects a customer or deletes a record is blocked until a human approves it.

Using n8n and a third-party approval service called Guardian, you can enforce this policy. Guardian acts as a gate in front of the irreversible send action, returning one of three responses: Allowed, Needs approval, or Denied. The workflow continues to the send action only if Guardian returns Allowed, or pauses at the approval step if Guardian returns Needs approval or Denied.

To implement the approval gate, place a Guardian node between draft generation and the send action. The approval flow involves triggering the workflow with a schedule or webhook, having the agent draft the email using an LLM node, then sending the payload to the Guardian API for policy evaluation. The workflow branches based on Guardian's response, allowing the email to be sent if Allowed, pausing for approval if Needs approval, or denying and logging the action if Denied.

The Guardian policy is defined in JSON rules that match on payload fields. For client emails, the policy might include conditions for client vs. internal recipients and actions like send, delete, or update. The payload sent to Guardian should include all necessary information for a human reviewer without requiring additional queries to the CRM or accounting system.

If an approval request remains unanswered for 24 hours, Guardian supports timeout policies to auto-deny, auto-approve (for low-stakes actions), or escalate to a manager. In n8n, handle expiration by listening for Guardian's timeout webhook and logging the event, with the option to retry the approval request with a different reviewer if needed.

If a failure occurs after approval, such as a send action error, the approval token should be single-use. If the send fails, log the error and do not retry without a new approval to prevent accidental double-sends. State management is crucial—store drafts in the Guardian payload, an n8n database, or an external store like S3 or Redis, depending on draft size and scalability requirements. Finally, ensure observability by setting up logging and monitoring for workflow performance and approval outcomes.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Designing Idempotent Retail APIs: Preventing Duplicate Orders During Retries

A customer places an order. The ERP creates it, but the connection drops before the ecommerce platform receives confirmation. The ecommerce platform retries the request.

  • Idempotent APIs prevent duplicate orders during retries.
  • Idempotency keys generated by clients help servers recognize retries.
  • Atomic transactions ensure order creation and record saving consistency.

AWS Agent Registry: How Runtime Tool Discovery Replaces Hardcoded Agent Wiring

Hardcoded tool catalogs break when your agent needs to choose between 200 MCP servers instead of five. AWS Agent Registry solves this by moving tool discovery from build time to runtime.

  • AWS Agent Registry replaces hardcoded tool wiring with runtime tool discovery.
  • Three-step process: Discover, Instantiate, Execute.
  • Metadata includes unique ID, description, schema definitions, and tags.

Hibernate Under the Hood. Part 7: Performance and Common Pitfalls

Performance issues are rarely the fault of Hibernate itself; more often, they are caused by its misuse. The key to success is identifying these issues before they manifest in production.

  • Enable SQL and Hibernate statistics logging to uncover performance issues
  • Address N+1 problem with JOIN FETCH, batch fetching, or DTO projections
  • Disable OSIV in production to avoid unexpected queries and connection pool issues

More from Wednesday 21 October →