Skip to content

Add word document generator from template - #284

Open
Nazish (nazishqassim) wants to merge 9 commits into
microsoft:mainfrom
nazishqassim:add-word-document-generator-from-template
Open

Add word document generator from template#284
Nazish (nazishqassim) wants to merge 9 commits into
microsoft:mainfrom
nazishqassim:add-word-document-generator-from-template

Conversation

@nazishqassim

Copy link
Copy Markdown
Contributor

Title: Add word-document-generator-from-template skill

## Summary

- Adds an instruction-only Copilot Studio skill that fills a Word template supplied at runtime (upload, SharePoint, OneDrive, or another connector) and writes a **new** DOCX without overwriting the original.
- Works for any document the template defines — policy, procedure, report, paper, briefing, SOP, or SOW — using user input, approved knowledge, uploaded files, and prior tool/connector results (e.g. Dataverse).
- Agent inspects the template, builds JSON that matches its headings/placeholders/repeating tables, generates section by section, and marks unsupported facts as `Not specified in approved sources`.
- README includes a generic template skeleton (styles, `{{placeholders}}`, one sample repeating row) plus example prompts; Leave Policy is only an illustration of the same pattern.

Word Document Generator from Template is a Copilot Studio skill that drafts any Word document—policy, procedure, report, paper, or similar—by filling a runtime template from an upload, SharePoint, OneDrive, or another connector. It uses only user input, approved knowledge, attached files, and prior tool/connector results, maps those into JSON that matches the template’s headings and repeating tables, preserves branding and layout, never overwrites the original file, and returns a new DOCX plus a short generation summary with gaps marked for human review.

Nazish (nazishqassim) and others added 6 commits August 14, 2026 08:43
- Ensure appClientId and tenantId are always required, regardless of directConnectUrl presence.
- Adjusted resolveConfig() to prevent early exits that could lead to misleading errors.
- Added 4 regression tests to enhance coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ctor results

- Updated the skill description to include user input and results from previous tool or connector calls.
- Modified the README to clarify the use of prior results and their integration into document generation.
- Adjusted metadata to reflect the inclusion of connector results as valid sources.
- Improved validation and generation rules to ensure accurate sourcing of information from approved knowledge, user files, and prior results.
… usage

- Enhanced the skill description to specify that the Word template can be uploaded or retrieved from SharePoint, OneDrive, or other connectors.
- Revised README to detail the template sourcing process and emphasize that the original template is never overwritten.
- Adjusted metadata to reflect the updated description and broadened the tags to include SharePoint and OneDrive.
- Improved instructions for locating and using the Word template during document generation.
- Revised README to replace the Information Security Policy template with the Leave Policy template, including updated document title and owner.
- Adjusted SKILL.md to reflect changes in document structure, including new leave types and updated source document titles for HR context.
- Enhanced examples to align with the new policy focus and ensure clarity in usage.
- Added a new section detailing the ideal structure for Word templates, including guidelines for using styles and placeholders.
- Included a "Do's and Don'ts" list to improve template design and ensure compatibility with the document generation process.
- Provided an example Leave Policy template to illustrate the recommended format and usage of placeholders.
…lity and template usage

- Revised the skill description to clarify that the generator can create various document types, including policy, procedure, report, and paper.
- Updated README to reflect changes in the template structure and provide clearer guidelines for document generation.
- Enhanced metadata description and tags to better represent the skill's capabilities and supported document types.
- Improved instructions for identifying and using the Word template during the generation process.
Copilot AI lite review requested due to automatic review settings August 14, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new submission to the submissions/ gallery: an instruction-only Copilot Studio skill for generating a new DOCX by filling a runtime-provided Word template (upload/SharePoint/OneDrive/connector), grounded in approved sources and prior tool/connector results.

Changes:

  • Added word-document-generator-from-template skill instructions for template inspection, JSON mapping, population, and validation while preventing template overwrite.
  • Added a human-facing README.md describing intended usage, inputs, and a generic Word template skeleton with examples.
  • Added metadata.json registering the skill for Copilot Studio with tags, author info, and versioning.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
submissions/word-document-generator-from-template/SKILL.md Defines the agent-run procedure and guardrails for filling a runtime Word template and saving a new DOCX.
submissions/word-document-generator-from-template/README.md Provides human-facing adoption guidance, template structure recommendations, and example prompts.
submissions/word-document-generator-from-template/metadata.json Registers the submission (name/description/platform/tags/author/version/dates).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 17, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (3)

submissions/word-document-generator-from-template/SKILL.md:86

  • source_ids is described as holding tool/connector names like Dataverse:accounts, but the JSON example and sources section use stable IDs like SRC-001. This inconsistency will cause the intermediate JSON to be structured differently depending on which part the agent follows.
- Treat prior tool and connector outputs as approved sources. Record the tool or connector name in `source_ids` (for example `Dataverse:accounts`, `SharePoint:policy-library`).

submissions/word-document-generator-from-template/README.md:43

  • The README prescribes {{placeholders}}, but Copilot Studio’s Word/Graph connector approaches typically require a specific templating mechanism (e.g., content controls), and the skill does not mandate any particular engine. As written, users could build templates that the runtime tooling can’t actually fill.
The same pattern works for every document type. Use **Word styles** (Heading 1,
Heading 2, Normal) and `{{placeholders}}` — not finished body text.

submissions/word-document-generator-from-template/SKILL.md:45

  • The skill assumes it can inspect a .docx template and then populate it while preserving formatting, but it doesn’t first require/verify that an actual Copilot Studio action/tool exists that can (a) read the template and (b) write a new .docx for the template’s placeholder/repeating-row syntax. Without that preflight, the procedure can’t be executed reliably.
1. Locate the Word template supplied at runtime. Obtain it from whichever source the user identified:
   - a file uploaded with the request;
   - SharePoint (library, folder, or site);
   - OneDrive; or
   - another connector or prior tool result that returns a `.docx` file.

@nazishqassim
Nazish (nazishqassim) marked this pull request as draft August 17, 2026 12:18
…dling, validation, and JSON structure. Introduce deterministic engine for filling and inspecting DOCX files, ensuring preservation of live fields and branding. Update metadata and README for clarity on usage and capabilities.
…idation logic. Enhance JSON structure handling and update documentation for better clarity on features and usage.
@nazishqassim
Nazish (nazishqassim) marked this pull request as ready for review August 17, 2026 13:06
Copilot AI review requested due to automatic review settings August 17, 2026 13:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.

Suppressed comments (1)

submissions/word-document-generator-from-template/scripts/docx_template.py:147

  • zipfile.ZipFile.read() can raise RuntimeError for encrypted/password-protected DOCX files (and zipfile.LargeZipFile for large ZIP64 archives). Currently _read_package() only wraps BadZipFile/OSError, so those cases would surface as an unhandled exception instead of a TemplateError with exit code 2.
    except (zipfile.BadZipFile, OSError) as exc:
        raise TemplateError(f"Cannot read DOCX package {source}: {exc}") from exc

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.

3 participants