Docx Generator
2 min read
The service is integrated into the following modules:
Functionality
The Docx Generator Service enables developers to generate .docx files from predefined templates. It is used as part of a tool or module.
This service is built on top of the docxtpl library, which provides template-based document generation capabilities.
Configuration
Default Configuration
{
"uploadSuffix": "_report_output.docx",
"uploadScopeId": null,
"uploadToChat": true,
"templateName": "template.docx",
"templateScopeId": null,
"templateFields": {
"date": "CURRENT_DATE",
"document_title": "Template Document"
},
"skipIngestion": true
}Field Name | Description | Type | Default Value | Required |
|---|---|---|---|---|
| The suffix of the generated docx file. | string |
| No |
| The scope id into which the generated docx file is uploaded. | string |
| No |
| Whether to upload the generated file to the chat. | boolean |
| No |
| The name of the template file. | string |
| No |
| The scope id of the template. | string |
| No |
| The fields to be replaced in the template. | string |
| No |
| Whether to skip the ingestion (chunking & embedding) of the generated file when uploaded to the knowledge base. | boolean |
| No |
Nested Types
TemplateFields
When customizing templateFields, ensure that each placeholder defined in your template has a corresponding field in the configuration.
To automatically insert the current date into your document, set the date field value to CURRENT_DATE.
Field Name | Description | Default Value | Type | Required |
|---|---|---|---|---|
| The date to be inserted in the template. If not explicitly defined, the current date will be selected. |
| string | No |
| The title of the document. |
| string | No |
Default Unique Template
Below you can find the default template that is used by the docxGenerator if no template is configured.
Doc Template.docxWord documentDownload
The List Bullet style must be added to Quick Style List in the template to have the docxGenerator work properly.

The colored boxes indicate how each section of the document is handled:
Blue - Fixed Content: These contain static elements that remain the same across all generated documents. This content is hardcoded into the template and is not dynamic. Examples include:
Client logo
Footer disclaimers
Page numbers
Orange - Configurable Content: Text in orange boxes is dynamically populated from the configuration. For example, if your configuration contains:
json"templateFields": { "document_title": "Template Document" }The service will replace the placeholder
{{document_title}}in the template with "Template Document" during generation.Important: The inserted text will inherit the style of the placeholder it replaces (e.g., font, size, colour).
Note: The service automatically replaces the
CURRENT_DATEplaceholder with the current date at runtime.
Red Box – Programmable Content Areas: This is a required placeholder used by module/tool to inject content into the document via code. The structure and presence of this box must remain unchanged in the template to allow proper integration.
Styling the template
Content added to the template, whether through code or by replacing placeholders, will inherit the styles defined in the template. Make sure to customize these styles in the template file to match your formatting and branding requirements.

Notes
Ensure that all fields are correctly configured to match the intended document generation and upload requirements.
The default values provided offer a baseline configuration that can be customized as needed.
Consider the implications of skipping ingestion and uploading to chat based on operational needs and workflow integration.
Full Json Schema
{
"properties": {
"uploadSuffix": {
"default": "_report_output.docx",
"description": "The suffix of the uploaded file.",
"title": "Uploadsuffix",
"type": "string"
},
"uploadScopeId": {
"default": null,
"description": "The scope id of the upload.",
"title": "Uploadscopeid",
"type": "string"
},
"uploadToChat": {
"default": true,
"description": "Whether to upload the file to the chat.",
"title": "Uploadtochat",
"type": "boolean"
},
"templateName": {
"default": "template.docx",
"description": "The name of the template file.",
"title": "Templatename",
"type": "string"
},
"templateScopeId": {
"default": null,
"description": "The scope id of the template.",
"title": "Templatescopeid",
"type": "string"
},
"templateFields": {
"additionalProperties": true,
"default": {
"date": "16/04/2025",
"document_title": "Template Document"
},
"description": "The fields to be replaced in the template.",
"title": "Templatefields",
"type": "object"
},
"skipIngestion": {
"default": true,
"description": "Whether to skip the ingestion of the file.",
"title": "Skipingestion",
"type": "boolean"
}
},
"title": "DocxGeneratorConfig",
"type": "object"
}