# ShinrAI for n8n

Protect text or documents before the next workflow step sends them to another system. The node returns protected data without copying the original input into its output. Credentials stay in n8n.

## Install

This package is a direct-install release; npm publication and n8n Cloud verification are separate release gates. On a self-hosted n8n installation, install the provided `.tgz` in the user directory's `nodes` folder, then restart n8n:

```sh
cd ~/.n8n/nodes
npm install --ignore-scripts --legacy-peer-deps /path/to/n8n-nodes-shinrai-0.1.0.tgz
```

For Docker, install into the persistent `/home/node/.n8n/nodes` directory. Use the supplied standard HTTP-node workflow for n8n Cloud while native-node verification is pending.

## Connect and run

Import a file from `workflows/`: `text-example`, `form-processing`, `document-sharing`, `ai-with-local-restoration`, `http-only-text`, `http-only-ai`, or `http-only-document`. Select credentials and replace the example destination/model URL before activating it. HTTP-only examples use **Header Auth** credentials: header name `Authorization`, value `Bearer YOUR_SHINRAI_KEY`. These examples need no community package. AI examples use a separate Header Auth credential for your existing model provider. Mappings remain within n8n and are excluded from model requests. Execution-content retention is disabled in these templates; enable it only for synthetic debugging.

The form webhook accepts JSON fields `name`, `email` and `message`, presents them as labeled text for detection, and exports protected text. Document webhooks accept a raw PDF/DOCX/TXT body with the correct Content-Type. The native document example sends a flattened PDF. The HTTP-only document example starts a job, polls for completion with a bounded wait, sends protected extracted text, then deletes the temporary job. Connect every ShinrAI HTTP step to the same credential, including polling, download and cleanup.

1. Create a **ShinrAI** credential with your ShinrAI API key. Keep the default hosted service URL unless using your own deployment.
2. Add a **ShinrAI** node after the step receiving customer input.
3. Select **Protect Text**, provide the input text, and choose pseudonyms, masking or labels.
4. Run the node. Connect the destination only to its protected output `text`.
5. Test with a synthetic name and email. Confirm the destination receives the protected version.

For documents, select **Protect Document**, choose the binary field and keep the default unique upload ID. Supported inputs: PDF, DOCX and UTF-8 TXT. Output `data` is a flattened protected PDF and `text` is protected extracted text. English/German OCR includes supported scans and embedded images. Uploads are limited to 10 MB; unsupported or incomplete processing stops the workflow.

**Private mappings contain originals.** Enable them only when you need local restoration. Keep the mapping on a separate workflow branch; pass only protected text to the model. Use **Restore Reply** afterward to restore recognized pseudonyms locally. Analyze intentionally returns findings containing originals and is not a protection step.

Keep **Settings → On Error → Stop Workflow** and leave **Always Output Data** disabled on protection steps. Native nodes detect “Continue on error” and stop that branch with a red execution hint before processing. n8n may still mark the overall execution successful when a branch returns no items; check the hint and downstream delivery. Do not enable an error branch or a destination expression that reads original input from an earlier node. Invalid keys, quota failures, unavailable processing and unsupported files stop the operation. Reusing an upload ID with different content/options is rejected. Outputs and mappings remain subject to n8n's own access and execution-retention settings.

Coverage is the configured workflow path, not other nodes, saved source data, or independent model connections. See `README.de.md` for German instructions. Tested host versions and real application evidence are recorded in the QA handoff; packaging alone is not live validation.

## Validated example

The [screenshots](screenshots/) show the actual installed test application with synthetic data. Replacement values vary between runs. The download includes shared example documents and an executable connection test in `../fixtures/`.
