Sitelet https://github.com/simstudioai/sim/pull/7069
Skip to content

feat(integrations): add Microsoft Word - #7069

Merged
waleedlatif1 merged 7 commits into
stagingfrom
feat/microsoft-word-integration
Aug 25, 2026
Merged

feat(integrations): add Microsoft Word#7069
waleedlatif1 merged 7 commits into
stagingfrom
feat/microsoft-word-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a Microsoft Word integration: block, 8 tools, 7 internal routes, contracts, OAuth service, icon, and docs
  • Microsoft Graph has no Word API — documents are drive items, so Sim builds and edits the .docx package itself and talks to Graph only through documented content endpoints
  • Operations: Create, Create from Template, Read, Replace Content, Append Content, Find and Replace Text, List/Search, Export as PDF

Details

  • Create / Replace generate a .docx from text with a small documented Markdown subset (#/##/###, - bullets, **bold** / *italic*); unsupported syntax stays as visible text rather than being dropped
  • Create from Template downloads a template, substitutes placeholders in memory, and uploads the result under a new name — the template is never written to. Graph's copy action is deliberately unused: it is async and only returns a monitor URL, which would force a poll before the copy could be filled
  • Append and Find and Replace edit word/document.xml in place via JSZip, so styles, numbering, images, headers, and footers survive. Append inserts before the body-level <w:sectPr> and emits no style references, since a user-owned document may not define Heading1
  • Find and Replace reassembles each paragraph before matching, so a placeholder Word split across runs is still found; when a match sits inside one run it is edited in place and that run's formatting is preserved. Covers headers and footers, and never matches across a paragraph break
  • Export as PDF uses content?format=pdf and follows Graph's redirect to the preauthenticated URL with the bearer token stripped cross-origin
  • Reuses the existing microsoft.word file selector and fixes it to forward driveId (it was ignoring it, unlike microsoft.excel, so the picker would list personal OneDrive documents even when a SharePoint drive was set)
  • Folder pickers reuse the shared onedrive.folders selector; Files.Read / Files.ReadWrite get Word-specific labels on the consent screen instead of the OneDrive-only wording

Type of Change

  • New feature (non-breaking change which adds functionality)

Testing

  • 26 new unit tests for the docx build / append / replace engine, including run-splitting, header coverage, XML escaping, literal $, and case sensitivity
  • Mutation-checked three of them: breaking the <w:sectPr> insertion, the $-escaping, and the in-place-replacement branch each turns a specific test red
  • bun run check:audits 33/33, bun run type-check clean, bun run lint clean
  • 1404 tests pass across the block, selector, OAuth, and deployment-availability suites
  • Not exercised against a live Microsoft tenant — every request shape is taken from the Graph reference docs, and no response field is mapped that the docs do not show

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 25, 2026 6:32pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a Microsoft Word integration that constructs and edits DOCX packages locally while using Microsoft Graph for file storage and PDF conversion.

  • Adds create, template, read, replace, append, find-and-replace, list/search, and PDF-export operations.
  • Adds OAuth configuration, selectors, contracts, block registration, generated metadata, icons, documentation, and deployment capability metadata.
  • Adds content-tag conflict detection for read-modify-write operations such as append and text replacement.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/microsoft-word/document.server.ts Implements DOCX generation, extraction, append, and text-replacement behavior with archive validation for mutation paths.
apps/sim/lib/microsoft-word/graph.server.ts Centralizes Microsoft Graph document downloads, uploads, conversion, metadata mapping, and content-tag conflict handling.
apps/sim/app/api/tools/microsoft_word/append/route.ts Implements guarded read-modify-write append behavior with conflict responses for detectable concurrent changes.
apps/sim/app/api/tools/microsoft_word/replace-text/route.ts Implements guarded in-place text replacement while preserving the surrounding DOCX package.
apps/sim/app/api/tools/microsoft_word/update/route.ts Implements the documented full-content replacement operation by generating and uploading a new DOCX package.
apps/sim/blocks/blocks/microsoft_word.ts Defines the workflow-facing Microsoft Word block, operations, parameters, and output mappings.

Sequence Diagram

sequenceDiagram
    participant Workflow
    participant Sim as Sim Word Tool
    participant Graph as Microsoft Graph
    Workflow->>Sim: Invoke Word operation
    alt Create or Replace Content
        Sim->>Sim: Build DOCX package
        Sim->>Graph: Upload document content
    else Append or Find and Replace
        Sim->>Graph: Fetch metadata and content tag
        Sim->>Graph: Download DOCX package
        Sim->>Sim: Edit package in memory
        Sim->>Graph: Re-check content tag
        Sim->>Graph: Upload edited package
    else Export PDF
        Sim->>Graph: "Request content?format=pdf"
        Graph-->>Sim: Redirect to converted file
        Sim-->>Workflow: Return PDF file
    end
Loading

Reviews (6): Last reviewed commit: "fix(microsoft-word): fail closed when a ..." | Re-trigger Greptile

Comment thread apps/sim/lib/microsoft-word/graph.server.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 43 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread apps/sim/app/api/tools/microsoft_word/create/route.ts Outdated
Comment thread apps/sim/app/api/tools/microsoft_word/update/route.ts
Comment thread apps/sim/app/api/tools/microsoft_word/replace-text/route.ts
Comment thread apps/sim/app/api/tools/microsoft_word/create-from-template/route.ts Outdated
Comment thread apps/sim/app/api/tools/microsoft_word/append/route.ts
Comment thread apps/sim/tools/microsoft_word/utils.ts
Comment thread apps/docs/content/docs/en/integrations/microsoft_word.mdx Outdated
Comment thread apps/sim/lib/api/contracts/tools/microsoft.ts Outdated
Comment thread apps/sim/lib/api/contracts/tools/microsoft.ts Outdated
Comment thread apps/sim/lib/api/contracts/tools/microsoft.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/app/api/tools/microsoft_word/append/route.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

…d-integration

# Conflicts:
#	apps/sim/tools/generated/tool-ids.ts
#	apps/sim/tools/generated/tool-metadata.ts
#	apps/sim/tools/generated/tool-outputs.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
waleedlatif1 merged commit 98a453d into staging Aug 25, 2026
29 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/microsoft-word-integration branch August 25, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant