Adeu icon

Adeu

Operate on Microsoft Word (.docx) files: extract LLM-friendly Markdown with CriticMarkup, navigate large documents via a structural outline, apply tracked changes and comments, generate sub-word diffs or one-step redline comparisons, and sanitize/finalize documents. Seven operations on the Document resource: (1) Extract Markdown — project a .docx into Markdown plus a Semantic Appendix (or a Fields Content Controls ledger in mode='fields'); toggle Clean View to simulate Accept All; pass an optional Page number or 'N-M' page range to fetch a slice of a large document. (2) Extract Outline — return a token-cheap structural map (headings with level, page number, end_page, paragraph style, has_table, footnote IDs) plus total_pages. Pair with Extract Markdown to navigate large documents. (3) Apply Edits — apply a JSON array of DocumentChange objects sequentially as native Word tracked changes (or manual strikethrough/underline formatting when Markup Mode is 'manual'); modify edits support match_mode ('strict'|'first'|'all'), regex (boolean), Markdown headings/bold/italic/'\n\n' splits/pipe tables, `{#cell:<id>}` empty-cell anchors, and single or multi-author comments; set_field fills content controls by CC:<N>, tag, or alias. (4) Apply Text Revision — hand back the COMPLETE revised clean text of the document and let the engine diff it against the clean view and write the tracked changes; it refuses CriticMarkup and partial-page text, and fails without returning a document when the applied result's clean text does not match the text supplied. (5) Generate Diff — produce a @@ Word Patch @@ sub-word diff, unified diff, structured DocumentChange JSON array, or a one-step redlined .docx comparison (`diffFormat='redlineDocx'`) between two .docx files. (6) Finalize Document — strip metadata, optionally accept all pending markup, and optionally lock the file read-only. (7) Hydrate Tool Output — re-attach a redlined .docx that Apply Edits, Apply Text Revision, or Generate Diff (`redlineDocx`) stashed while running as an AI Agent tool; place it on the main line downstream of the Agent, because n8n's tool wrapper strips binaries from tool output. DocumentChange schema (used by Apply Edits): each object has a 'type' field discriminator, and changes in a batch evaluate SEQUENTIALLY against the state produced by prior changes. type='modify' requires target_text (string — plain text resolves across hyperlinks, cross-references, and bookmarks; empty table cells emit `{#cell:<id>}`) and new_text (string — supports '#'–'######' headings, '**bold**', '_italic_', '\n\n' paragraph splits, and Markdown pipe tables `| H1 | H2 |\n|---|---|\n| A | B |`; omit new_text with a comment to annotate without changing text; empty string deletes); optional comment (string or `[{text, author?}]`); optional match_mode ('strict'|'first'|'all', default 'strict'); optional regex (boolean, default false — when true, target_text is an ES2022 RegExp pattern with optional inline flags like `(?i)`, and new_text may reference $1, $2 capture groups). type='set_field' requires field (string like 'CC:3', tag, or alias from Extract Markdown mode='fields') and value (string — checkboxes take true/false, dates YYYY-MM-DD, dropdowns a listed option); optional match_mode and comment. type='accept' or type='reject' requires target_id (string like 'Chg:12' from the Markdown projection); optional part (e.g. 'word/header1.xml' when the same id exists in several parts); optional comment. type='reply' requires target_id (string like 'Com:45') and text (string). type='insert_row' requires target_text (string), position ('above' or 'below'), and cells (array of strings). type='delete_row' requires target_text (string). Never wrap new_text in CriticMarkup tags like {++ ++} or {-- --}; the engine applies tracking automatically. Never target text already wrapped in another author's pending tracked change; accept or reject their change first by target_id. Binary handling for AI Agents: this tool cannot receive .docx files through JSON arguments because JSON cannot carry binary data. To process a document, set 'Document Source' to 'From Another Node' and 'Source Node Name' to the exact name of the workflow node that produced the .docx binary (typically the trigger node, e.g. 'Gmail Trigger', 'When clicking Test workflow', or an HTTP Request node configured to download a file). Node names are case-sensitive and must match the canvas label exactly. For the Generate Diff operation, set both 'Original Source Node Name' and 'Modified Source Node Name' independently.

Document → Finalize

AI-generated

Summary

Sanitizes and finalizes a .docx document by stripping metadata, resolving or preserving tracked changes, and optionally applying read-only protection.

Inputs

  • documentSource — Specifies whether to read the document from connected input or from a named upstream node.
  • sourceNodeName (required) — The exact canvas label of the upstream node containing the binary file when reading from another node.
  • sourceBinaryId — Optional binary storage ID used to retrieve the document during multi-turn AI interactions.
  • reasoning — Optional explanation of why the document is ready for finalization, primarily used for auditability in AI Agent workflows.
  • binaryPropertyName (required) — The name of the binary property on the input item containing the .docx file (defaults to 'data').
  • outputBinaryPropertyName (required) — The name of the binary property where the finalized .docx file will be written (defaults to 'data').
  • sanitizeMode — Sanitization behavior: 'baseline' (strip RSID and proofing metadata), 'full' (strip metadata and enforce/accept resolved tracked changes), or 'keep-markup' (strip metadata while preserving comments and tracked changes).
  • acceptAll — When Sanitize Mode is 'full', automatically accepts all pending tracked changes before finalization.
  • authorOverride — When Sanitize Mode is 'keep-markup', replaces the original author names on all preserved tracked changes and comments with this string.
  • protectionMode — Sets document editing restriction: 'none' (unlocked) or 'read_only' (enforces native Word read-only mode).

Output shape

a binary file

Returns the incoming workflow item updated with the finalized .docx binary file attached under the specified Output Binary Property.

Examples

Example 1: Full sanitization for external distribution

Set Sanitize Mode to 'Full', Accept All Tracked Changes to true, and Protection Mode to 'Read Only'.

Example 2: Anonymizing redlines before client review

Set Sanitize Mode to 'Keep Markup' and Author Override to 'Legal Team'.

Links

Discussion