2026-08-22 17:36:38 +02:00
# Nodes — nextcloud collabora
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
Six flow nodes in the palette plus one config node. All six point at the same **nc-collab-config ** (gear menu, not in the palette). Without config, nothing works.
2026-08-22 17:10:34 +02:00
## Backends
2026-08-22 17:36:38 +02:00
| Backend | Typical URL | Role |
|---------|-------------|------|
| Nextcloud | `https://cloud.example.com` | Files (WebDAV) + Office API (OCS) |
2026-08-22 21:27:02 +02:00
| Collabora CODE | `http://code:9980` (intern HTTP; fallback `http://<bridge-ip>:9980` ) | Conversion (`/cool/...` ) on Docker bridge |
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
Auth: **username + app password ** . Not your account password.
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
Default output folder if you omit a path: `/Dokument/OfficeOut/` (or set your own via `destNcPath` ).
2026-08-22 17:10:34 +02:00
---
2026-08-22 17:36:38 +02:00
## How they fit together
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
nc-collab-config (URLs + app password)
2026-08-22 17:10:34 +02:00
│
┌────┼────┬────────────┐
▼ ▼ ▼ ▼
collabora-* nc-office collabora-wopi collabora-bridge
2026-08-22 17:36:38 +02:00
(direct CODE) (NC OCS) (health/WOPI) (pipelines + save)
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
**Rules of thumb **
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
- PDF in Nextcloud → `collabora-bridge` **ncFileToPdf **
- Fill template in NC → **fillTemplateSave ** or `nc-office template:fillFields`
- Open in browser → `nc-office` **document:direct **
- Convert in memory only → `collabora-convert`
- List field names → `collabora-extract` or bridge **extractToPayload **
- Check CODE is alive → `collabora-wopi` **capabilities **
2026-08-22 17:10:34 +02:00
---
2026-08-22 17:36:38 +02:00
## Common `msg` fields
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
| Field | Meaning |
|-------|---------|
| `ncPath` | Path in the user's files, e.g. `/Documents/contract.docx` |
| `fileId` | Nextcloud numeric file id (resolved from `ncPath` if missing) |
| `payload` | Raw data already in the flow (Buffer or HTML string) |
2026-08-22 17:10:34 +02:00
| `format` | pdf, png, docx, html, … |
2026-08-22 17:36:38 +02:00
| `destNcPath` | Exact destination path |
| `destFolder` / `destName` | Folder + name (default folder `/Dokument/OfficeOut/` ) |
| `fields` / `transform` | JSON to merge into a template |
| `templateNcPath` | Extra template file for convert |
| `compareNcPath` | Older version for diff PDF |
| `operation` | Overrides the node dropdown |
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
Errors go to `msg.error` and turn the node red. The flow does not fail silently.
2026-08-22 17:10:34 +02:00
---
## 1. collabora-convert
2026-08-22 17:36:38 +02:00
Convert a file to another format via CODE. Does **not ** save to Nextcloud — output is `msg.payload` (Buffer).
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
**In: ** `msg.payload` or WebDAV GET `msg.ncPath` . Optional `templateNcPath` , `compareNcPath` , `format` .
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
**Out: ** `payload` , `filename` , `format` , `contentType` , `statusCode` .
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
inject { ncPath: "/Documents/contract.docx", format: "pdf" }
2026-08-22 17:10:34 +02:00
→ collabora-convert → debug
```
---
## 2. collabora-extract
2026-08-22 17:36:38 +02:00
List structure inside a document (content controls, fields, etc.). JSON out, no file.
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
**In: ** same as convert. Filter: node dropdown or `msg.filter` (default `contentcontrol` ).
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
inject { ncPath: "/Templates/contract.docx" }
2026-08-22 17:10:34 +02:00
→ collabora-extract → function → collabora-transform
```
---
## 3. collabora-transform
2026-08-22 17:36:38 +02:00
Write values into a document via CODE. Requires `msg.fields` or `msg.transform` .
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
msg.ncPath = "/Templates/contract.docx"
msg.fields = { "Customer": "ACME Ltd", "Date": "2026-08-22" }
2026-08-22 17:10:34 +02:00
→ collabora-transform
```
2026-08-22 17:36:38 +02:00
Save yourself afterwards if the file should live in Nextcloud.
2026-08-22 17:10:34 +02:00
---
## 4. collabora-wopi
2026-08-22 17:36:38 +02:00
Health checks and WOPI helpers — not conversion.
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
| Operation | Purpose |
|-----------|---------|
| `capabilities` | First test that CODE responds |
| `discovery` | mime → editor URL |
2026-08-22 17:10:34 +02:00
| `buildEditor` | `wopiSrc` + `token` → `editorUrl` |
2026-08-22 17:36:38 +02:00
| `checkFileInfo` / `getFile` | Debugging |
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
Public editor URLs go through Nextcloud (`collaboraPublicUrl` ), not the internal CODE IP.
2026-08-22 17:10:34 +02:00
---
## 5. nc-office
2026-08-22 17:36:38 +02:00
Nextcloud richdocuments OCS — templates, fields, editor URL, assets.
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
| Operation | Summary |
|-----------|---------|
| `templates:list` | List templates |
| `templates:create` | New file from template |
| `template:extractFields` | Field JSON via NC |
| `template:fillFields` | Fill + save in NC |
| `document:direct` | `editorUrl` for logged-in user |
| `document:public` | Same with `shareToken` |
| `files:convert` | NC → NC conversion |
| `assets:create` | One-shot insert URL for open editor |
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
inject { ncPath: "/Documents/contract.docx" }
2026-08-22 17:10:34 +02:00
→ nc-office (document:direct) → debug editorUrl
```
---
## 6. collabora-bridge
2026-08-22 17:36:38 +02:00
Ready-made pipelines — what you'll use most day to day.
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
| Operation | Does |
|-----------|------|
| `ncFileToPdf` | NC file → PDF in OfficeOut |
| `ncFileToPng` | Preview PNG |
| `ncFileToHtml` | HTML export |
2026-08-22 17:10:34 +02:00
| `htmlToOffice` | HTML → docx/pdf … |
2026-08-22 17:36:38 +02:00
| `fillTemplateSave` | Template + fields → save in NC |
| `compareVersionsPdf` | Diff PDF |
| `extractToPayload` | Field JSON in msg |
| `createAssetLink` | `assetUrl` |
2026-08-22 17:10:34 +02:00
```
2026-08-22 17:36:38 +02:00
inject { ncPath: "/Documents/contract.docx" }
2026-08-22 17:10:34 +02:00
→ collabora-bridge (ncFileToPdf)
→ debug destNcPath
```
2026-08-22 17:36:38 +02:00
Chain your existing OCS nodes (Talk, Mail, share link) after bridge: PDF lands in `/Dokument/OfficeOut/` , then share or send.
2026-08-22 17:10:34 +02:00
---
## Config: nc-collab-config
2026-08-22 17:36:38 +02:00
Create under the gear icon in Node-RED. All six flow nodes pick the same config instance.
2026-08-22 17:10:34 +02:00
2026-08-22 17:36:38 +02:00
| Field | Example |
|-------|---------|
| nextcloudUrl | `https://cloud.example.com` |
2026-08-22 21:27:02 +02:00
| collaboraUrl | `http://code:9980` — intern CODE är **HTTP ** ; fallback `http://<bridge-ip>:9980` efter `docker network connect bridge nextcloud-node-red` |
| collaboraPublicUrl | `https://docs.domain.name` (publik, browser/WOPI) |
2026-08-22 17:36:38 +02:00
| username + app password | Nextcloud login |
2026-08-22 17:10:34 +02:00
2026-08-22 21:27:02 +02:00
Intern CODE körs utan TLS (`http://` ) — publik åtkomst går via reverse proxy (HTTPS).
### createAssetLink (assets)
`collabora-bridge createAssetLink` / `nc-office assets:create` POSTar form-urlencoded
(`path=Dokument/logotyp.png` , relativt användarens filrot) mot
`<nextcloudUrl>/apps/richdocuments/assets` . `200 {url}` = asset-URL skapad;
`404` = filen finns inte i användarens rot (eller fel `nextcloudUrl` ) — felet innehåller status + svarskropp.
2026-08-22 17:36:38 +02:00
CODE IP is detected when you run `./install.sh` — see `.env.example` .