Skip to content

Feature Request: Custom template support for AI-generated Office documents (DOCX, XLSX, PPTX) #5431

@LexioJ

Description

@LexioJ

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 feat: PDF Template Workflow #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 feat: PDF Template Workflow #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions