@neuraltrust/n8n-nodes-trustguard
is a community node that makes an
n8n workflow a TrustGuard collector. It calls
/v1/evaluate and routes each item to one of four outputs — Allow,
Report, Transform, Block — so the verdict becomes a branch you can see on the canvas
rather than a value you have to remember to check.
It is a regular app node on the main path. It is not n8n’s built-in Guardrails node, not a
LangChain sub-node you attach to the AI Agent, and not an Agent tool gate: the policy lives in your
NeuralTrust collector rather than in the workflow, every verdict carries a trace_id that
reconciles with Activity, and transform rewrites the payload in flight.
Coverage
Ask — a workflow cannot prompt anyone mid-run, so the node applies Block
and leaves
trustguard.status as ask for you to branch on. From 0.2.0 it no
longer fails on it.
Use it when you already build AI workflows in n8n and want enforcement to be an explicit edge
in the graph. Not when the guarantee has to hold for traffic you do not control — the gate
exists only where you wire it, so a second workflow calling a model directly is unguarded. That is
a gateway.
Limits. Block and redact are conditional because the node routes but does not stop: an item on
the Block output that you wire back into the AI Agent is monitoring, not blocking. Tool-level
coverage is only what your graph makes explicit — there is no hook inside an AI Agent node’s own
loop.
Full comparison: Coverage.
Before you start
Keep the policy in Report mode for the first rollout. Report downgrades every rule to
report, so findings appear in Activity without breaking traffic. Switch to Enforce once the
finding volume looks right — see Policies.1. Install the node
In n8n, Settings → Community nodes → Install a community node, and enter:2. Create the credential
Add a NeuralTrust TrustGuard API credential before you add the node, so the node picks it up on first open.
Test posts a one-word
protocol: all ping to /v1/evaluate. A pass proves the key, the base
URL and egress all work — do it now rather than debugging it inside a workflow.
3. Gate the input
Add NeuralTrust TrustGuard between the trigger and the AI Agent, with Operation set to Evaluate Input:output from
{{ $json.trustguard.blockedMessage }}; a webhook workflow wants Respond to Webhook with
status 403, which webhook-403.json
works through.
Input Mode decides what gets sent:
The role matters: an Output-phase rule scoped to
assistant, or an indirect-injection rule scoped
to tool, only fires if the message carries that role. Text prefills
{{ $json.chatInput }} on Evaluate Input and {{ $json.output }} on Evaluate Output;
Messages prefills {{ $json.messages }} and accepts either a literal JSON array typed into
the field or an expression that resolves to one — n8n does not parse a json parameter for a
node, so the node does it itself.
4. Scan the output
Add a second node after the AI Agent with Operation set to Evaluate Output. It sendsdirection: output, so your Output-phase rules apply, and it prefills {{ $json.output }}.
The node runs on a complete item, so an output-side block lands before the item reaches whatever
answers the user — unless the workflow already streamed the response, in which case the tokens
have gone and the verdict is detection after the fact.
5. Know how each verdict lands
Only
allow and skip reach Allow. Anything else reaches Block, so a verdict a future TrustGuard
release adds is denied rather than forwarded while you wait for a node update.
guardrailsInput is the field the node writes the evaluated text to, on every branch: the masked
text on Transform, Blocked by NeuralTrust TrustGuard. trace_id=… on Block and on ask,
and the original text otherwise. It is the field to read downstream.
Alongside the verdict the node writes a
trustguard object onto the item:
findings is copied from the response for every verdict that carries them, not only report.
workflowId, workflowName and executionId are output metadata only — they are never sent in
the evaluate body, because /v1/evaluate rejects unknown top-level keys with a 400.
Wiring several outputs into one downstream node makes that node execute once per connected
output. To tally verdicts in one place, put a Merge node in between and set it to the number
of inputs you connect.
6. Set the options
Options is an n8n collection, so an option you have not added is not sent at all — the Default column below is what the field prefills with once you click Add option.collector_key, consumer_id, session_id and attributes.model.provider are sent only when
set. protocol, attributes.content_type and attributes.model.name are always sent, the last
as an empty string when Model Name is blank.
Add Session ID and keep its prefilled {{ $json.sessionId }}: leave the option off and
TrustGuard synthesises a session per request, so Activity cannot group turns the way your chat
does. Add Consumer ID if the collector has per-consumer policy
overrides, or every request resolves to the default policy — in a chat workflow the natural source
is the trigger’s authenticated user. Protocol should stay llm for chat workflows.
7. Choose fail-open or fail-closed
The node fails closed by default, and Fail Open on Unreachable is deliberately narrow. It covers only connect errors, timeouts, HTTP 502/504, and HTTP 429 after retries are exhausted. Those are retried first: three attempts in total. An HTTP retry honoursRetry-After up to 5s; a
transport error has no header to read, so it always backs off 0.25s then 0.5s.
Everything else fails closed even with fail-open on:
- HTTP 401/403, and 503 entitlement failures
- any other 4xx/5xx
- a non-JSON
200, or a verdict this version of the node does not recognise - a
transformed_payloadthat cannot be applied safely - an empty or unresolved Text expression
- TLS and certificate failures — an untrusted certificate looks like a connect error, but it is a configuration fault rather than an outage, so fail-open does not cover it. A corporate MITM proxy without a trusted CA will therefore fail every item.
code on the cause chain (ECONNREFUSED,
ENOTFOUND, ETIMEDOUT, …) as well as from the message text, because n8n rewrites those codes
into prose before a node ever sees them.
On Error
Fail Open on Unreachable is scoped to transport failures. n8n’s own Settings → On Error is not, and it is the setting most likely to open a hole by accident:
No On Error setting can put an unevaluated item on Allow. Failures route to Block, which
n8n still relocates to the error output when that mode is selected. Filter on
trustguard.evaluated === false to find every item that reached a branch without being evaluated —
it is set both on a fail-open Allow item and on a Block-routed failure.
8. Verify
With a jailbreak rule in Enforce mode, run the workflow with:trustguard.trace_id on the
blocked item is the same identifier the finding carries in Activity, so use it to reconcile a
run with what the console shows. Then check the inverse — an ordinary prompt leaves on Allow
and reaches the agent.
As an AI Agent tool
The node setsusableAsTool, so n8n also offers it as a tool an AI Agent can call. That path is
built for reporting, not enforcement.
Templates
If you can install the node,examples/ holds nine
importable workflows covering every operation, option, output and failure mode — start with
01-input-gate-four-verdicts.json.
For instances where installing a community node is not an option, the
node repository also ships three workflows
built from HTTP Request + Switch that call the same endpoint:
Attach a Header Auth credential (
Authorization: Bearer tgk_…) after importing. Never paste a key
into the workflow JSON — it is stored unencrypted and travels with every export.
Limits to keep in mind
- The gate is only where you wire it. Even inside a guarded workflow, a branch that routes around the node is unguarded.
- Each guarded direction is one round trip, and the node evaluates items one at a time — a batch of 50 items is 50 calls. Timeout is per attempt, so a 5s timeout over three attempts can hold an execution open for more than 15s before the item fails.
- Transform rewrites text and tool-call arguments only. Tool name and call id values are checked
against the request and never changed, a transformed tool call is re-emitted in OpenAI
{id, type, function}form, a call that arrived without anidcannot be transformed at all, and a non-text content part cannot be masked — those refuse and fail closed rather than partially applying. - There is no hook inside the AI Agent loop. n8n does not expose one, so a tool call cannot be gated before it executes the way the LangChain middleware gates one. Route tool traffic through TrustGate where that matters.
NeuralTrust/n8n-nodes-trustguard.