Documents
Redline two contract versions and email the changes
Compare the current and proposed versions of a Word contract, make a tracked-changes redline and an HTML report, and email them — or stop when nothing changed.
Exotic Liquids has sent back Northwind's supply agreement with changes. This workflow compares the two Word files, emails the legal team a side-by-side report in the message body with a redline attached, and ends quietly when the versions are identical.
Steps: start form → Compare Documents → Branch by Condition → Send Email.
1. Start form
In the workflow's start form add two Attachments fields, current_contract and proposed_contract, each Documents, at most 1 file, required. The files arrive as {{form.current_contract}} and {{form.proposed_contract}} (lists of one file; the first file is used).
2. Compare the versions
{
"type": "doc_compare",
"label": "Compare versions",
"config": {
"original": "{{form.current_contract}}",
"revised": "{{form.proposed_contract}}",
"mode": "words",
"ignore_whitespace": true,
"redline": "docx",
"redline_style": "tracked",
"report": "html",
"output_name": "Supply agreement — Exotic Liquids",
"output_var": "comparison"
}
}The canvas shows words diff + redline docx, html report → comparison.
- Compare: Words shows a changed number or name as one change rather than a whole changed line. Use Sentences for long clauses, Lines for plain text files.
- Redline: Word with Word tracked changes gives a
.docxin which every change is a real tracked change by "UserTasks compare": lawyers can accept or reject them in Word. Coloured marks insertions in green underline and deletions in red strikethrough instead. - Report file: HTML saves the side-by-side report as a file as well; it is also in
{{comparison_html}}.
When the term changed from 24 to 36 months and Chang's price from 19.00 to 19.50, the run shows:
{ "variable": "comparison", "mode": "words", "identical": false, "similarity": 93.9, "stats": { "added": 0, "removed": 0, "changed": 2, "unchanged": 2, "…": "…" }, "changes": 2, "files": { "redline_docx": "Supply agreement — Exotic Liquids-redline.docx", "report": "Supply agreement — Exotic Liquids.html" } }and {{comparison.changes}} is:
[
{ "type": "changed", "old_text": "24", "new_text": "36" },
{ "type": "changed", "old_text": "00", "new_text": "50" }
]Word mode splits 19.00 into 19, . and 00, so only the changed part is listed; the report and the redline show it in context.
3. Stop when nothing changed
Add Branch by Condition with one branch for identical versions:
{
"type": "condition",
"label": "Any changes?",
"config": {
"branches": [
{ "label": "Identical", "logic": "AND", "rules": [{ "field": "{{comparison_identical}}", "operator": "is_true", "value": "" }] }
],
"has_else": true
}
}Leave Identical unconnected (or add a Log step), and connect Else to the email. To ask for a full review only when a lot changed, add a branch on {{comparison_similarity}} with less than 80.
4. Email the report and the redline
{
"type": "send_email",
"label": "Send redline to legal",
"config": {
"to": "legal@northwind.example",
"subject": "Supply agreement: {{comparison.stats.changed}} changes from Exotic Liquids ({{comparison_similarity}}% similar)",
"body": "<p>Andrew, Exotic Liquids returned the supply agreement. The changes are below; the tracked-changes copy is attached.</p>{{comparison_html}}",
"attachments": "{{comparison_redline_docx}}, {{comparison_report}}"
}
}{{comparison_html}} uses inline styles only and escaped text, so it renders in mail clients and cannot inject markup from the documents. Several attachments separated by commas are all attached.
What the reader gets
- The email body: a header with both file names and "2 changed · 0 added · 0 removed · 93.9% similar", then a two-column table — old on the left, new on the right, changed words highlighted, and long unchanged stretches collapsed to "… N unchanged lines …".
Supply agreement — Exotic Liquids-redline.docx: the revised text with the changes as tracked changes, opening with a "Redline: …" heading and the statistics.Supply agreement — Exotic Liquids.html: the same report as a standalone page.
Variations
- PDF instead of Word:
"redline": "pdf"(always coloured) or"both";"report": "pdf"gives a printable list of the changes. PDFs use the standard fonts (Latin characters only). - Store the history: add a Data step that saves
{{comparison_similarity}},{{comparison.stats.changed}}and{{comparison_redline_docx.url}}per round. - Summarise for the business owner: add Run Agent with "Explain these contract changes in plain English: {{comparison.unified}}".
- One document with tracked changes: to list the changes already tracked inside a single Word file, use Read Document and
{{document.structure.tracked_changes}}.