n8n and AI Red Teaming Integration
Focus
Focus
Prisma AIRS

n8n and AI Red Teaming Integration

Table of Contents

n8n and AI Red Teaming Integration

Learn about n8n integration architecture, authentication, response modes, multi-turn conversations, and file attack support in AI Red Teaming.
Where Can I Use This?What Do I Need?
  • Prisma AIRS (AI Red Teaming)
  • Prisma AIRS AI Red Teaming license
  • Prisma AIRS AI Red Teaming deployment profile
  • An active n8n instance (cloud or self-hosted) with a published workflow
  • The production webhook URL from your n8n workflow
n8n is a workflow automation platform for building AI agents. A typical n8n agent chains a Webhook trigger node, an AI model node, and a Respond to Webhook node. When you connect an n8n agent to AI Red Teaming, the platform sends attack prompts as HTTP POST requests to the agent's published webhook URL and reads the AI model's responses. No identity provider registration or OAuth 2.0 token exchange is required. The authentication is handled entirely by the credentials configured on the n8n Webhook node.

Authentication Options

AI Red Teaming supports the following authentication methods for n8n targets. The method you configure in AI Red Teaming must match the authentication configured on the n8n Webhook node exactly.
  • None—No authentication. The webhook accepts requests from any caller. Use only in isolated test environments.
  • Header Auth—AI Red Teaming sends a secret value in a custom HTTP header with every request. You define the header name and value in both n8n and AI Red Teaming. Available on the Webhook node only.
  • Basic Auth—AI Red Teaming sends the username and password in the standard Authorization: Basic header using base64 encoding. You provide the credentials in plain text when creating the target; AI Red Teaming encodes them automatically.
n8n has no inbound OAuth 2.0 support. OAuth 2.0 is an outbound credential type in n8n for connecting to external services, not for authenticating inbound webhook requests. Do not attempt to configure OAuth 2.0 for n8n targets in AI Red Teaming.

Configure Your n8n Workflow

Before you add an n8n agent as a target in AI Red Teaming, configure and publish your n8n workflow:
Use the n8n AI assistant to build and debug your workflow. It suggests node configurations based on your use case and resolves common configuration errors before you run a scan.
  1. In your n8n instance, create a new workflow or open an existing one.
  2. Add a Webhook trigger node as the first node:
    • Set HTTP Method to POST.
    • Set Respond to Using Respond to Webhook Node for REST mode, or to Streaming for streaming mode.
    • Configure Authentication to match the method you plan to use in AI Red Teaming (either Header Auth or Basic Auth).
  3. (For text-only attacks) Add the AI model node (for example, Google Gemini — Message a Model or OpenAI — Message a Model) and connect it to the Webhook node. In the model node, set the Message field to reference the prompt from the request body:
    {{ $json.body.chatInput }}
  4. (For multi-turn conversations) Add a Simple Memory node before the AI model node and key the memory on the session ID from the request:
    {{ $('Webhook').item.json.sessionId }}
    AI Red Teaming generates a stable session ID per conversation and sends it in the sessionId field. The Simple Memory node uses this ID to maintain context across turns while keeping separate conversations isolated from each other.
  5. (For multimodal file attack support with Supports File Upload Option) Add an IF node after the Webhook node to check whether $json.body.files has items, then configure each branch:
    IF node (contains a file):
    1. A Convert to File node (operation: Move Base64 String to File) with Base64 Input Field set to body.files[0].data.
    2. An Extract From File node (operation: Extract From PDF) with Input Binary Field set to data.
    3. Add the AI model node (for example, Google Gemini — Upload a media file) and connect it to the Extract From File node. Set the Message field to the extracted text:
      {{ $json.text }}
    IF node (doesn't contain a file):
    1. Connect the Webhook node directly to the AI model node you added in Step 3.
    The IF node is required. Without it, an empty files array on a text attack causes the Convert to File node to error and the entire target fails validation.
  6. (For REST mode) Add a Respond to Webhook node as the last node in the workflow. Set Respond With to JSON and map the AI model's output to the output field, for example:
    {{ { "output": $json.content.parts[0].text } }}
  7. Toggle the workflow to Active (Published) in the n8n editor.
  8. The n8n provides two webhook URLs for every Webhook node. Only the production URL works for AI Red Teaming scans. In the Webhook node, copy the Production URL. It uses the path pattern /webhook/<path>. You will enter this URL when creating the target in AI Red Teaming.
    Do not use the test URL (/webhook-test/<path>). It accepts only one request before it stops listening, so the first attack in a scan succeeds and all subsequent attacks fail with a connection error.

Response Modes

AI Red Teaming supports two response modes for n8n targets. The response mode you configure in AI Red Teaming must match the Respond setting on the n8n Webhook node.
Moden8n Webhook Node SettingBehavior
Standard (REST)Using Respond to Webhook NodeAI Red Teaming sends a single request and waits for a single complete response. The Respond to Webhook node must return a JSON body with an output field containing the AI model's response text.
StreamingStreamingThe n8n workflow emits the AI response incrementally via Server-Sent Events (SSE). AI Red Teaming reads the stream, concatenates chunks, and reconstructs the full response. Each chunk must include a content field. Streaming ends when the end-of-stream marker is received.
  • The Webhook node's Respond setting also affects scan validity.
    • Setting it to Immediately returns a static confirmation message ({"message": "Workflow was started"}) rather than the AI model's response, causing AI Red Teaming to score all attacks against that static string.
    • Use Using Respond to Webhook Node for REST mode or Streaming for streaming mode.
  • The output field name for REST mode and content for streaming mode are server-enforced defaults. If the AI model node in your workflow returns a different field name (for example, text instead of output), update the Respond to Webhook node to map the model's output to the expected field name.

Multi-turn Conversations

AI Red Teaming uses a client-session mode for multi-turn conversations with n8n agents. In this mode, AI Red Teaming generates a stable, deterministic session ID for each conversation in a scan and includes it in the sessionId field of every request. Your n8n workflow must include a Simple Memory node keyed on this session ID to maintain conversational context across turns.
This differs from other multi-turn modes in AI Red Teaming:
  • In stateful mode (used by some other connection types), the server returns a session ID that AI Red Teaming reads and chains into subsequent requests. n8n never returns a session ID, so stateful mode does not apply.
  • In stateless mode, AI Red Teaming resends the full conversation history in each request. n8n agents that use a memory node expect a session ID, not a full transcript. Resending history would double-count against the memory node.
Client-session mode solves both problems: AI Red Teaming owns the session ID, n8n's memory node holds the history, and no transcript is resent. Session IDs are isolated per conversation, so parallel conversations within a scan do not contaminate each other's memory.
Multi-turn scanning requires a Simple Memory node in your n8n workflow keyed on {{ $json.body.sessionId }}. Without this node, each turn in a multi-turn attack is stateless from n8n's perspective, even though AI Red Teaming sends a consistent session ID.

Multimodal File Attacks

AI Red Teaming delivers file attacks as base64-encoded data inside the JSON request body. For n8n targets, the file is included in a files array element alongside the MIME type. Your n8n workflow must decode this data and extract text before passing it to the AI model.
The required n8n workflow path for file attack support:
AI Red Teaming → POST {"chatInput": "...", "sessionId": "...", "files": [{"mime_type": "application/pdf", "data": "<base64>"}]} → n8n Webhook node → IF node (check: $json.body.files has items) → Convert to File (Move Base64 String to File; Base64 Input Field: body.files[0].data) → Extract From File (Extract From PDF; Input Binary Field: data) → AI Agent node (prompt contains the extracted document text) → Respond to Webhook node
The IF node checking for file presence is required. Without it, text-only attacks (which send an empty files array) cause the Convert to File node to error and the target fails validation. During target creation, AI Red Teaming sends a small benign PDF to probe whether the workflow handles files correctly and sets the target's file-capability flag accordingly. A target that fails the file probe is still saved and runs text-only attacks.
Known limits for n8n file attacks:
  • File attacks are not available in multi-turn scans. AI Red Teaming skips file prompts during multi-turn attacks. An n8n target with multi-turn enabled runs text-only attacks regardless of whether file support is configured.
  • Self-hosted instances may lack binary nodes. Administrators can exclude n8n nodes via the NODES_EXCLUDE environment variable. If the Convert to File or Extract From File nodes are excluded, the target fails the file probe and runs text-only.

Deployment Considerations

The following behaviors are specific to your n8n deployment type and affect how you configure and run AI Red Teaming scans.
For n8n Cloud targets, configure a rate limit on the target in AI Red Teaming. When your plan's concurrency limit is exceeded, n8n Cloud queues requests rather than returning a 429 error. The queued requests add latency that can exceed the 100-second edge timeout and cause attacks to fail. AI Red Teaming defaults the target request timeout to 90 seconds, which stays under the Cloud cap, but rate limiting prevents the queue from building up in the first place.
If you are on the n8n Cloud free tier, monitor your execution quota before running large scans. Each attack message consumes one execution, and an extensive red teaming scan can exhaust the monthly quota quickly. Exceeding the limit pauses workflow executions until the next billing cycle, interrupting in-progress scans. Consider upgrading your plan or scheduling scans to stay within your monthly allowance.