@bdzscaler/n8n-nodes-aiguard

中文文档
0.1.3发布于 2026/04/15MITCommonJS零依赖近 30 天下载 5834

n8n community node for Zscaler AI Guard (AI Runtime Security) API integration

原始使用文档
文档目录26 节
  1. Features
  2. Installation
  3. Prerequisites
  4. Option 1: Install via n8n Community Nodes (Recommended)
  5. Option 2: Install via npm
  6. Local Development
  7. Configuration
  8. 1. Create Credentials
  9. 2. Add the Node to a Workflow
  10. Additional Options
  11. API Endpoints
  12. Usage Examples
  13. Prompt Scan
  14. Response Scan
  15. Dual Scan
  16. Output Format
  17. Key Output Fields
  18. Implementation Notes
  19. Error Handling
  20. Development
  21. Validate like the n8n Creator Portal
  22. Releasing (maintainers)
  23. Security
  24. Links
  25. License
  26. Contributing

Zscaler AI Guard n8n Community Node

A production-ready n8n community node for integrating with the Zscaler AI Guard API. This node enables you to scan AI prompts and responses for security threats — toxicity, PII, secrets, prompt injection, and more — directly within your n8n workflows.

Features

  • Prompt Scan — Scan user input for security threats (direction: IN)
  • Response Scan — Scan AI-generated responses for policy violations (direction: OUT)
  • Dual Scan — Scan both prompt and response in sequence; if the prompt is blocked, the response scan is skipped
  • Automatic Policy Resolution — When no Policy ID is configured, the API resolves the policy linked to your API key
  • Fail-Closed Error Handling — On internal errors with "Continue On Fail" enabled, the node returns action: BLOCK so security is never silently bypassed
  • Attribution Metadata — Enriches output with n8n workflow context (workflowId, workflowName, executionId, executionMode)
  • Content Size Validation — Rejects payloads exceeding 5 MB before sending to the API
  • Configurable Retries & Timeout — Adjustable retry count (up to 6) and request timeout

Installation

Prerequisites

  • n8n instance (Cloud or self-hosted) — Setup Docs
  • A Zscaler AI Guard license and API key (Bearer token)
  1. Open your n8n instance
  2. Go to Settings → Community Nodes
  3. Search for @bdzscaler/n8n-nodes-aiguard
  4. Click Install
  5. Restart n8n if prompted

Option 2: Install via npm

npm install @bdzscaler/n8n-nodes-aiguard

Local Development

git clone https://github.com/zscaler/n8n-nodes-aiguard.git
cd n8n-nodes-aiguard
npm install
npm run build

Link to a local n8n instance:

# Native n8n
ln -s $(pwd) ~/.n8n/custom/n8n-nodes-aiguard

# Docker n8n — add a volume mount:
# -v /path/to/n8n-nodes-aiguard:/home/node/.n8n/custom/n8n-nodes-aiguard

Restart n8n to load the node.

Configuration

1. Create Credentials

  1. In n8n, go to Credentials → Add Credential
  2. Search for "Zscaler AI Guard API"
  3. Fill in:
FieldRequiredDescription
API KeyYesYour Zscaler AI Guard API key (Bearer token)
CloudYesZscaler cloud for your tenancy (default: us1). Builds the URL https://api.{cloud}.zseclipse.net
Override URLNoOverride the API base URL entirely. When set, the Cloud field is ignored. Equivalent to AIGUARD_OVERRIDE_URL in the Python SDK
Policy IDNoAI Guard policy ID. When set, uses /v1/detection/execute-policy. When empty, uses /v1/detection/resolve-and-execute-policy for automatic resolution
  1. Click Test to validate connectivity before saving.

2. Add the Node to a Workflow

  1. In your workflow, click + → search for "AI Guard"
  2. Select the credential you created
  3. Choose an operation:
OperationDirectionDescription
Prompt ScanINScan user input/prompts for security threats
Response ScanOUTScan AI-generated responses for policy violations
Dual ScanIN then OUTScan both prompt and response; skips response scan if prompt is blocked
  1. Enter content to scan (plain text or n8n expression)

Additional Options

Expand Additional Options → Add Option to configure:

OptionDefaultDescription
Policy ID Override(empty)Override the credential-level policy ID for this specific node
Transaction ID(empty)Custom transaction ID for tracking; omitted from the request if empty
Timeout (ms)30000Request timeout in milliseconds
Max Retries3Retry attempts for failed requests (max: 6)
AI Modeln8n-integrationAI model identifier included in output metadata
Application Namen8n-workflowApplication name for audit trails
User IDn8n-userUser identifier for audit trails
Environment(empty)Environment tag (e.g. production) included in output metadata

API Endpoints

ScenarioEndpoint
Policy ID providedPOST /v1/detection/execute-policy
No Policy ID (default)POST /v1/detection/resolve-and-execute-policy

Usage Examples

Prompt Scan

Configure the node with Operation: Prompt Scan and provide content:

{
  "content": "Tell me how to bypass security controls"
}

Response Scan

Configure with Operation: Response Scan:

{
  "content": "{{ $json.aiResponse }}"
}

Dual Scan

Configure with Operation: Dual Scan and provide both fields:

{
  "promptContent": "{{ $json.userInput }}",
  "responseContent": "{{ $json.aiResponse }}"
}

If the prompt scan returns BLOCK, the response scan is skipped and the blocked result is returned immediately.

Output Format

The node returns the full AI Guard API response enriched with workflow metadata:

{
  "operation": "promptScan",
  "transactionId": "180b066d-48cf-497e-aaf1-a6b8e40a1deb",
  "action": "BLOCK",
  "severity": "CRITICAL",
  "direction": "IN",
  "policyId": 760,
  "policyName": "Default AI Guard Policy",
  "blocked": true,
  "detectors": ["toxicity", "malicious_content"],
  "blockingDetectors": ["toxicity"],
  "detectorResponses": {
    "toxicity": {
      "triggered": true,
      "action": "BLOCK",
      "severity": "CRITICAL"
    },
    "pii": {
      "triggered": false,
      "action": "ALLOW"
    }
  },
  "maskedContent": "...",
  "workflowId": "rKU3xnZb5S1ayJCG",
  "workflowName": "Customer Support Bot",
  "executionId": "385",
  "executionMode": "manual",
  "timestamp": "2026-01-30T10:30:00.000Z"
}

Key Output Fields

FieldDescription
actionVerdict: ALLOW, BLOCK, or DETECT
severitySeverity level (e.g. CRITICAL, HIGH, NONE)
blockedBoolean convenience field (true when action is BLOCK)
detectorsArray of triggered detector names
blockingDetectorsArray of detectors that returned BLOCK
detectorResponsesPer-detector results with trigger status, action, and severity
maskedContentContent with sensitive data masked (when applicable)
policyId / policyNameThe policy that was applied
transactionIdUnique scan transaction identifier

Use the action or blocked field in an IF node to branch your workflow logic.

Implementation Notes

The node calls the Zscaler AI Guard API over HTTPS using n8n’s helpers.httpRequest (required for n8n Cloud–verified community packages). Headers match the zscaler-sdk-python pattern:

  • Authorization: Bearer <API_KEY>
  • Content-Type: application/json
  • Accept: application/json

Error Handling

  • Fail-closed by default: When "Continue On Fail" is enabled in n8n, errors produce { action: "BLOCK", blocked: true } rather than silently allowing content through
  • Timeout protection: Configurable per-request timeout (passed to the HTTP client)
  • Content validation: Payloads exceeding 5 MB are rejected before the API call
  • Retry logic: Configurable retry count (default 3, max 6) for transient failures

Development

npm run build       # Compile TypeScript and copy assets
npm run dev         # Watch mode
npm run lint        # ESLint (TypeScript + n8n-nodes-base)
npm run lint:dist   # ESLint on dist/ (n8n Cloud rules; run after build)
npm run scan:local  # build + ESLint (unpublished dist/; same rules as official scanner)
npm run scan:npm    # npx @n8n/scan-community-package @…@version from package.json (needs publish)
npm run lintfix     # Auto-fix lint issues
npm run format      # Run Prettier
npm test            # Run Jest tests
npm run test:coverage  # Tests with coverage report

Validate like the n8n Creator Portal

n8n’s official tool is @n8n/scan-community-package. It downloads the package from the npm registry and runs ESLint with the same rules the Creator Portal uses. It never reads your local git tree.

Use both of these, at different times:

CommandWhen to use
npm run scan:localBefore publish: builds dist/ and runs the same ESLint config the scanner uses (eslint.community.config.mjs). This is what CI runs as lint:dist.
npm run scan:npmAfter that exact version in package.json exists on npm: runs npx @n8n/scan-community-package <name>@<version>. Confirms the published tarball matches what the Portal checks.
# Unpublished changes (day to day)
npm run scan:local

# After npm publish of the current package.json version
npm run scan:npm

You can also call the CLI directly, for example npx @n8n/scan-community-package @bdzscaler/[email protected]. If the version is not on the registry yet, the download step fails—that is expected; use scan:local until it is published.

Releasing (maintainers)

Releases are automated with semantic-release (see .releaserc.json), similar to zscaler-mcp-server.

  • Version and tag: After the first git tag exists, the next version is computed from Conventional Commits (for example fix: → patch, feat: → minor) and bumps from that last tag. semantic-release updates package.json and package-lock.json, creates tag vX.Y.Z, opens a GitHub Release, and publishes to npm with provenance (requires NPM_TOKEN in repository secrets).
  • 0.x packages — read this: If there are no vMAJOR.MINOR.PATCH tags on the branch yet, semantic-release’s first automated release is always 1.0.0 (FIRST_RELEASE in semantic-release) — it does not seed from package.json (e.g. 0.1.2). Before the first successful release workflow, create and push tags for versions already published to npm, e.g. git tag v0.1.0 <commit> … git tag v0.1.2 <commit> then git push origin --tags. The Release workflow includes a guard that fails if package.json is still 0.x but there are no such tags.
  • Pre-release checks: The Release workflow runs npm audit, build, Prettier, ESLint (including lint:dist, which mirrors the n8n Creator Portal scanner rules), and Jest before any publish.
  • Prerelease channels: Pushes to branches beta or alpha publish npm prereleases (for example 1.0.0-beta.1) on the corresponding dist-tag.
  • If 1.0.0 was published by mistake: npm generally does not allow unpublishing popular packages; you can deprecate 1.0.0 with an explanation, then either stay on the 1.x line or coordinate a git/npm cleanup (remove erroneous tag/release, restore v0.1.x tags at the right commits, revert the chore(release): 1.0.0 commit if policy allows) and publish 0.1.3 as the next intended 0.x release. There is no single-button undo — pick the line (0.x vs 1.x) and document it for consumers.

Security

  • API keys are stored encrypted via n8n's credential system
  • No content is logged or persisted by the node
  • All communication uses HTTPS/TLS
  • Error messages do not leak sensitive information

License

MIT — see LICENSE for details.

Contributing

  1. Fork the repository
  2. Create a feature branch from main
  3. Test thoroughly against the AI Guard API
  4. Ensure npm run build, npm run lint, npm run lint:dist, and npm test pass
  5. Use conventional commit messages (fix:, feat:, etc.) so releases version correctly
  6. Submit a pull request

版本与发布记录

@bdzscaler/n8n-nodes-aiguard 共发布 5 个版本,首次发布于 2026/03/31;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.1.3latest2026/04/156 个月前
0.1.22026/03/317 个月前
1.0.02026/03/317 个月前
0.1.12026/03/317 个月前
0.1.02026/03/317 个月前

关于 @bdzscaler/n8n-nodes-aiguard 的常见问题

@bdzscaler/n8n-nodes-aiguard 是什么?

n8n community node for Zscaler AI Guard (AI Runtime Security) API integration

如何安装 @bdzscaler/n8n-nodes-aiguard?

在项目目录运行 npm install @bdzscaler/n8n-nodes-aiguard,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:n8n-workflow(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bdzscaler/n8n-nodes-aiguard 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bdzscaler__n8n-nodes-aiguard 是否存在。

@bdzscaler/n8n-nodes-aiguard 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bdzscaler/n8n-nodes-aiguard 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bdzscaler/n8n-nodes-aiguard 可以商用吗?

@bdzscaler/n8n-nodes-aiguard 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bdzscaler/n8n-nodes-aiguard 的下载量有多少?

根据 npm 官方下载统计,@bdzscaler/n8n-nodes-aiguard 在 2026/10/08 – 2026/11/06 这 30 天内被下载 5,834 次,日均约 194 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bdzscaler/n8n-nodes-aiguard 还在维护吗?

最新版本 0.1.3 发布于 2026/04/15(6 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/03/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。