Actions2
Fill Template
AI-generatedSummary
Fill a DOCX or ODT template stored on Nextcloud by replacing {d.variable} placeholders using provided data, optionally appending conditional annex documents, and output the filled document either saved back to Nextcloud or returned as a binary output.
Inputs
- Template From (required) — Choose how to specify the template file: select from a list or provide a path expression.
- Template Folder — When selecting from a list, specify the Nextcloud folder containing the template file.
- Template File — When selecting from a list, pick the DOCX or ODT template file located in the chosen template folder.
- Template File Path — When using path mode, provide the full Nextcloud path to the DOCX or ODT template file; this must be a valid existing file path.
- Data Mode (required) — Select how to supply the template data: key-value pairs for simple variables or a JSON object for complex/nested data and array repetition support.
- Template Variables (Key-Value Mode) — When using key-value mode, specify each variable name (matching template placeholders) and its corresponding value, supporting n8n expressions.
- Data (JSON Mode) — When using JSON mode, provide a JSON object that will be accessible as the 'd' context in the template, allowing complex and array data insertion.
- Output Format (required) — Choose the output format of the filled document: DOCX (default) or PDF (requires LibreOffice installed on the n8n server).
- Output Mode (required) — Select whether to save the filled document to Nextcloud or return it as a binary output for further use in the workflow.
- Output Destination — When saving to Nextcloud, specify how to select the output destination: by browsing folders + filename or providing a full path expression.
- Output Folder — When using folder browser mode, select the Nextcloud folder where the filled file will be saved.
- Output File Name — When using folder browser mode, specify the filename only for the output file, supporting expressions and matching the output format extension.
- Output File Path — When using path mode, specify the full path (including filename) on Nextcloud where the filled document will be saved; folder must exist.
- Binary Property Name — When returning the file as binary, define the binary property name holding the file data on the output item.
- Output File Name (Binary) — When returning binary output, specify the filename (with extension matching output format) for the binary file.
- Annexes Folder — Specify the Nextcloud folder containing DOCX annex files that can be conditionally appended after the main filled template.
- Conditional Annexes — Define one or more annex files to append based on conditions evaluated against input data values. Multiple matching annexes are merged with automatic page breaks.
Output shape
a list of items, each with JSON metadata about the fill operation success, paths, variables used, and optionally with a binary file if returning as binary output.
If output mode is 'saveToNextcloud', the node returns JSON summarizing the upload success and file details. If output mode is 'returnBinary', the node returns the filled document binary in the specified binary property along with JSON metadata. Supports both single and multiple input items processing. Validation errors occur if required template or output paths/names are missing.
Examples
Example 1: Fill a simple contract template with client data provided as key-value pairs, save the filled DOCX file to a specified Nextcloud folder with a dynamic filename.
Template From: From List; Template Folder: /Documents/Templates; Template File: contract.docx; Data Mode: Key-Value Pairs with variables mapped; Output Format: DOCX; Output Mode: Save to Nextcloud; Output Folder: /Documents/Filled; Output File Name: contract_{{ $json.client }}.docx
Example 2: Fill an invoice template passing a complex JSON object containing arrays for line items, output as PDF attached to an email.
Template From: By Path; Template File Path: /Documents/Templates/invoice_template.odt; Data Mode: JSON Object with full invoice data; Output Format: PDF; Output Mode: Return as Binary; Binary Property Name: invoicePdf; Output File Name: invoice_{{ $json.invoiceNumber }}.pdf