# n8n-nodes-workflow-custom

This is an n8n community node package that provides three powerful nodes:

1. **Workflow Reporter** - Report workflow execution data to your dashboard for analytics and monitoring
2. **Smart Document Parser** - Automatically detect and parse documents (PDF, Excel, CSV, JSON, XML, and more) into structured JSON
3. **HTML → PDF** - Convert HTML string content into a PDF binary for storage, email, or approvals

[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

### Community Nodes (Recommended)

1. Go to **Settings > Community Nodes**
2. Select **Install**
3. Enter `n8n-nodes-workflow-custom` in **Enter npm package name**
4. Agree to the [risks](https://docs.n8n.io/integrations/community-nodes/risks/) of using community nodes
5. Select **Install**

After installation, restart n8n to load the new node.

### Manual Installation

To install manually:

```bash
npm install n8n-nodes-workflow-custom
```

For Docker-based n8n installations, add this to your docker-compose.yml or Dockerfile.

## Credentials

This node requires **Workflow Reporter API** credentials:

- **API Token**: Your organization-specific API token (provided by your dashboard administrator)

## Operations

### Report Workflow Execution

Send workflow execution data to your dashboard, including:

- Workflow ID and name
- Execution ID
- Start/end timestamps
- Execution status (success/failed)
- Custom metadata (environment, client, tags)
- Error messages (if failed)

## Nodes Included

### 1. Workflow Reporter

Report workflow execution data to your dashboard for analytics and monitoring.

**Usage:**

1. Add the **Workflow Reporter** node to your workflow
2. Select or create **Workflow Reporter API** credentials
3. Configure optional metadata fields (environment, client, tags)
4. The node automatically captures workflow execution data

**Example:**

```
Trigger → [Your workflow nodes] → Workflow Reporter
```

### 2. Smart Document Parser

Automatically detect and parse documents into structured JSON data.

**Supported Formats:**

- PDF, DOCX, XLSX, CSV
- JSON, XML, YAML
- Images (with optional OCR)
- ZIP archives, Email files (EML)
- Plain text

**Key Features:**

- Automatic file type detection
- Multiple output modes (per-page, per-row, attachments)
- Configurable error handling
- Consistent JSON output structure

**Example:**

```
HTTP Request → Smart Document Parser → Process Structured Data
```

**Documentation:**

- [Full README](nodes/SmartDocumentParser/README.md)
- [Usage Examples](nodes/SmartDocumentParser/USAGE_EXAMPLES.md)
- [Quick Start](nodes/SmartDocumentParser/QUICK_START.md)

### 3. HTML → PDF

Render HTML content into a PDF and output it as a binary property.

**Usage:**

1. Add the **HTML → PDF** node to your workflow
2. Provide your HTML string (expressions supported, e.g. `{{$json.html}}`)
3. Choose binary property name (default `data`) and optional file name
4. Configure page format, margins, and orientation if needed

**Notes:**

- The package depends on `puppeteer`, which is installed automatically with the community node and downloads a compatible Chromium.
- In restricted environments, set `PUPPETEER_EXECUTABLE_PATH` to a system Chrome/Chromium and ensure fonts are available in the container/host.
- If you prefer Playwright, the node can fall back to it when installed separately.

#### Troubleshooting: "Could not find Chrome"

If you see an error like: "Could not find Chrome (ver. XXX)", it means Puppeteer cannot locate a browser binary.

Fix it in one of these ways:

- Option A — Use system Chromium and point Puppeteer at it
  - Debian/Ubuntu (Docker):
    - Install packages: `apt-get update && apt-get install -y chromium fonts-liberation libnss3 libatk-bridge2.0-0 libx11-xcb1 libxcomposite1 libxdamage1 libxfixes3 libglib2.0-0 libgbm1 libgtk-3-0 libasound2`
    - Set env var in your n8n container: `PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium` (sometimes `/usr/bin/chromium-browser` or `/usr/bin/google-chrome`)
  - Alpine (Docker):
    - Install packages: `apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont`
    - Set `PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium`

- Option B — Let Puppeteer download Chrome
  - Ensure `PUPPETEER_SKIP_DOWNLOAD` is not set (or set to `false`) when installing the community node.
  - Reinstall the community node from n8n, or exec into the container and run: `npx puppeteer browsers install chrome`

- Option C — Use Playwright
  - Install `playwright` in your n8n environment; the node will fall back to it.

## Compatibility

- Requires n8n version 1.0.0 or above
- Node.js 18.0.0 or above

PDF rendering specifics:

- Puppeteer downloads Chromium during installation; outbound network may be required unless you provide a system browser via `PUPPETEER_EXECUTABLE_PATH`.
- Install necessary fonts for your language/scripts to ensure correct PDF text rendering.

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
- [GitHub repository](https://github.com/djwz2001/custom_nodes)
- [Report Issues](https://github.com/djwz2001/custom_nodes/issues)

## License

[MIT](LICENSE.md)

[MIT](https://github.com/n8n-io/n8n-nodes-starter/blob/master/LICENSE.md)
