nextcloud / nextcloud/richdocuments

Custom template support for AI-generated Office documents (DOCX, XLSX, PPTX)

Open
#5,431 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feature: templates
Dominant language
JavaScript
Stars
453
Forks
147
Avg merge
14h 54m
Merged PRs (30d)
83

Description

Summary

When using the Nextcloud Assistant to generate Office documents (DOCX, XLSX, PPTX) via the AI pipeline, the resulting files always use default Collabora styling. There is currently no way for users or administrators to provide a custom template so that AI-generated documents match organizational branding, formatting standards, or predefined layouts.

Current Behavior

The AI document generation pipeline works as follows:

  1. The user enters a prompt in the Nextcloud Assistant UI.
  2. A configured LLM provider generates structured text content.
  3. The richdocuments TaskProcessing providers (TextToTextTaskType variants for DOCX/XLSX/PPTX) pass this content to Collabora Online for conversion.
  4. The resulting file is saved to the user’s Nextcloud storage with default Collabora styling.

There is no template selection step, no admin configuration for output formatting, and no way to inject branding (logos, fonts, color schemes, slide masters, etc.) into the generated file.

Desired Behavior

Users should be able to select a custom template before (or as part of) triggering AI document generation. The generated content should be placed into that template rather than a blank default document.

Two levels of template support would be ideal:

  • Admin-level: Administrators can designate global organization templates (reusing the existing appdata_[instanceid]/richdocuments/empty_templates/ infrastructure) that are available to all users during AI generation.
  • User-level: Users can optionally select a personal template from their own template folder (as already configured in Collabora user settings) when generating a document via the Assistant.

Proposed Implementation

The building blocks for this already exist in richdocuments:

  1. TemplateManager already handles discovery and management of both system-wide and user templates.
  2. TemplateFieldService (introduced with the PDF Template Workflow, PR #3798) already interfaces with Collabora’s API for template-based document population.
  3. The TaskProcessing providers for DOCX, XLSX, and PPTX are the integration point where a template reference could be injected before Collabora renders the final file.

A concrete implementation path could be:

  1. Extend the DOCX/XLSX/PPTX TaskProcessing providers to accept an optional templateId input parameter alongside the existing text prompt.
  2. Add a template selection step to the Assistant UI (similar to the existing “+” / new file dialog in Files) that queries available templates via the existing TemplateManager API.
  3. When a template is selected, pass it to Collabora via the existing template-population mechanism used by TemplateFieldService, substituting the LLM-generated content into the document body while preserving all template styling.
  4. When no template is selected, fall back to the current default behavior.

This approach is additive and backward-compatible — it requires no breaking changes to the existing pipeline.

Use Cases

  • Government & enterprise organizations that require all documents to carry official letterheads, color schemes, or footer/header layouts.
  • Teams using PPTX generation who need presentations to match a corporate slide master.
  • Organizations using XLSX generation who want AI-generated spreadsheets to open with pre-configured column headers, named styles, or a company logo.

Related

  • PR #3798 — PDF Template Workflow (introduces TemplateFieldService, the technical foundation for template population via Collabora API)
  • nextcloud/server#22426 — File templates (broader unified template handling; still unresolved)
  • nextcloud/assistant — The UI layer where a template selector step would need to be added

Additional Context

The existing template system for manual document creation (via the “+” button in Files) and the AI generation pipeline are currently completely disconnected. Bridging these two systems would make the AI generation feature significantly more useful in professional and regulated environments, while reusing already-maintained infrastructure rather than introducing new complexity.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing TemplateManager and TemplateFieldService, then inspect the DOCX, XLSX, and PPTX TaskProcessing providers and the Assistant UI entry point. Compare these with the template flow described in PR #3798. Done means a selected admin or user template can reach generation while the no-template path continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, frontend, full-stack
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.