> ## Documentation Index
> Fetch the complete documentation index at: https://docs.experio.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Document Templates

> Upload and manage templates for AI-generated documents including presentations, reports, and more

## Overview

Document Templates let you upload branded files that the AI uses as a base for generated documents. When a template is active, generated output inherits its branding, structure, and formatting. Templates are organized by **categories** (e.g., Case Study, Proposal, Resume) and support multiple output formats.

Navigate to **Settings > Document Templates** in the admin panel.

## Template Categories

Categories group templates by purpose. When users generate a document, the **Generate button** shows templates organized by category for easy discovery.

### Default Categories

The system ships with six seeded categories:

| Category              | Description                               |
| --------------------- | ----------------------------------------- |
| **General**           | General-purpose document templates        |
| **Case Study**        | Templates for case study documents        |
| **Resume**            | Templates for resume and CV documents     |
| **Proposal**          | Templates for business proposals          |
| **Executive Summary** | Templates for executive summary documents |
| **List of Projects**  | Templates for project listing documents   |

### Managing Categories

Navigate to **Settings > Template Categories** in the admin panel.

* **Create** — Add a new category with a name and optional description. A URL-friendly slug is auto-generated from the name.
* **Edit** — Update the name, description, or active status.
* **Deactivate** — Inactive categories and their templates are hidden from users.
* **Delete** — Permanently removes the category. Templates in a deleted category become uncategorized.

<Tip>
  To seed the default categories after a fresh deployment, run:

  ```bash theme={null}
  cd server && pipenv run python manage.py seed_template_categories
  ```
</Tip>

## Supported Template Types

| Type        | Extension | Description                                                                  |
| ----------- | --------- | ---------------------------------------------------------------------------- |
| **pptx**    | `.pptx`   | PowerPoint presentation with slide layouts and branding                      |
| **docx**    | `.docx`   | Word document with custom styles, headers/footers, and branding              |
| **message** | —         | Formatted chat response (no file download — output appears directly in chat) |

<Note>
  The **message** type produces a formatted response in the chat window instead of a downloadable file. Use it for structured text outputs like summaries or formatted lists.
</Note>

## Adding a Template

1. Click **Add Template** — this opens a full-page form
2. Fill in:
   * **Name** — identifier used in the `/generate` command (must be unique within the selected category)
   * **Type** — select the output format (`pptx` or `message`)
   * **Category** — select from available categories (e.g., General, Case Study, Proposal)
   * **Description** — optional notes about the template
   * **Retrieval Instructions** — guides what data the AI should retrieve (see below)
   * **Output Instructions** — guides how the AI should format the output (see below)
   * **File** — upload a template file (required for pptx; not applicable for message)
3. Click **Create**

For PPTX templates, the system parses the file and extracts slide layout names. Templates must contain at least one recognized layout name to be accepted.

### Retrieval Instructions

This field tells the AI **what data to look for** during the retrieval/scope phase of generation. It is injected into the pipeline before the AI begins gathering context.

**Examples:**

* `"Find all projects for this client including project name, client name, dates, and budget"`
* `"Retrieve the candidate's work history, education, skills, and certifications"`
* `"Gather financial metrics, market analysis, and competitive positioning data"`

### Output Instructions

This field tells the AI **how to structure and format** the final output. It is injected into the report writer phase.

**Examples:**

* `"Format as a professional case study with Executive Summary, Challenge, Solution, and Results sections"`
* `"Create a one-page executive summary with key findings, recommendations, and next steps"`
* `"Organize as a bulleted project list grouped by client, with dates and status for each project"`

<Tip>
  Retrieval and output instructions work together: retrieval instructions ensure the right data is gathered, and output instructions ensure it is presented in the right format. Both are optional — when left blank, the AI uses conversation context and its default formatting.
</Tip>

## PPTX-Specific: Supported Layout Names

PPTX templates must include slide layouts named after the following supported types (case-insensitive):

| Layout Name      | Purpose                                      |
| ---------------- | -------------------------------------------- |
| `section_header` | Section divider slide with accent background |
| `bullets`        | Bullet point content slide                   |
| `quote`          | Centered quotation with attribution          |
| `two_column`     | Side-by-side content columns                 |
| `table`          | Data table with styled header row            |
| `key_metric`     | Big number/KPI with supporting text          |
| `timeline`       | Horizontal timeline or roadmap               |
| `blank`          | Minimal spacer slide (footer only)           |
| `comparison`     | Structured VS comparison layout              |
| `closing`        | Thank you / end slide                        |

Layout matching is **case-insensitive**: `SECTION_HEADER`, `Section_Header`, and `section_header` all match.

### The `blank` Layout

The `blank` layout is **critical** — it serves as the fallback for any slide whose layout name doesn't match the supported list. Templates missing a `blank` layout will show a warning in the admin UI.

<Warning>
  If your template has no layout named "blank", slides using unsupported layout names will fall back to the last available layout, which may produce unexpected results.
</Warning>

## What Templates Provide

Templates control the **visual branding** of generated documents:

* Slide master backgrounds (gradients, images, shapes) — for PPTX
* Custom Word styles (Title, Heading 1–4, Normal, List Bullet) — for DOCX
* Logo placement and footer design
* Font families and default text styling
* Color schemes defined in the slide master
* Retrieval guidance (what data to gather)
* Output formatting guidance (how to structure the result)

**Templates do NOT control content placement.** For PPTX, the AI uses programmatic builders to position titles, bullet points, tables, and charts at precise coordinates on each slide.

## What Works

* Multiple templates can be active simultaneously
* Users select a template from the **Generate button** (wand icon) in the chat input
* Templates are grouped by category in the Generate dropdown
* The `/generate` command supports `--type`, `--template`, and `--category` flags
* Each supported PPTX layout type uses the matching template layout for its background/styling
* Layout badges in the admin show green for supported layouts, gray for unsupported

## Known Limitations

| Limitation                          | Detail                                                                                                                                               |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Only 10 PPTX layout types**       | Custom layout names (e.g., `TITLE_AND_BODY`, `BIG_NUMBER`, `MAIN_POINT`) are not supported. Slides requesting these fall back to the `blank` layout. |
| **No per-layout content placement** | Template placeholder positions are not used for content. All content is placed programmatically at fixed coordinates.                                |
| **No image placeholders**           | Picture/image placeholders in templates are ignored.                                                                                                 |
| **Title slide uses blank layout**   | The title slide does not use a template's `title` layout — it's drawn programmatically.                                                              |
| **No template preview**             | There is no visual preview of the template in the admin UI — download and open in PowerPoint/Keynote to inspect.                                     |

## Managing Templates

### Activate / Deactivate

* Only **active** templates appear in the Generate dropdown for chat users
* Multiple templates can be active at the same time
* Click **Deactivate** to hide a template from users without deleting it

### Edit

Click **Edit** to open the full-page form where you can update:

* Name, description, category, and type
* Retrieval instructions and output instructions
* Upload a replacement file (re-parses layouts for PPTX)

### Download

Click **Download** to get the original template file for inspection or editing.

### Delete

Permanently removes the template and its file data. This cannot be undone.

## Creating a Compatible PPTX Template

To create a PPTX template that works with Experio:

1. Open PowerPoint or Google Slides
2. Go to **View > Slide Master**
3. Create or rename layouts using the supported names listed above
4. Design each layout with your branding (backgrounds, logos, fonts)
5. Ensure a layout named `blank` exists
6. Save as `.pptx`
7. Upload to Experio

<Tip>
  Start with an existing Experio template (download one from the admin) and customize it to match your brand. This ensures all required layout names are present.
</Tip>

## Creating a Compatible DOCX Template

To create a Word template that works with Experio:

1. Open Microsoft Word or Google Docs (export as `.docx`)
2. Customize **Styles** (Home > Styles) for Title, Heading 1–4, Normal, and List Bullet with your brand fonts and colors
3. Add headers/footers with your logo and page numbers
4. Save as `.docx` — the body content is replaced at generation time; styles and headers/footers are preserved
5. Upload to Experio as type **Word (DOCX)**

Experio maps content to template styles using best-effort matching. Standard style names (`Heading 1`, `Normal`, `List Bullet`, etc.) work best.

## Using Templates in Chat

### Generate Button

A **Generate button** (wand icon) appears in two places when at least one template is active:

* **Chat input toolbar** — next to the model selector
* **Artifact Panel header** — shown when a long-form response is open on the right

From either location:

1. Click the **wand icon**
2. Browse categories in the dropdown (e.g., General, Case Study, Proposal)
3. Hover over a category to see its templates — each shows a type badge (`pptx`, `docx`, or `msg`)
4. Click a template name

Behavior differs slightly by entry point:

* **From the chat input toolbar** — the `/generate` command is filled into the chat input with the appropriate flags so you can review or edit it before pressing **Enter**.
* **From the Artifact Panel** — the `/generate` command is sent immediately using the current conversation context, so the agent can reformat the long response into the chosen template without a separate prompt step.

### Manual Command

You can also type the command directly:

```
/generate --type pptx --template "blue"
```

With a category:

```
/generate --type pptx --category "Case Study" --template "Standard"
```

#### Command Flags

| Flag         | Required | Description                                                                              |
| ------------ | -------- | ---------------------------------------------------------------------------------------- |
| `--type`     | Yes      | Output format: `pptx` or `message`                                                       |
| `--template` | No       | Template name (case-sensitive match)                                                     |
| `--category` | No       | Category name (case-insensitive match). When omitted, lookup is not filtered by category |

#### Template Lookup Priority

When resolving which template to use, the system checks in this order:

1. **Category + Template name** — both `--category` and `--template` specified
2. **Template name + Type** — only `--template` specified (backward-compatible)
3. **Category + Type** — only `--category` specified (uses first active template in that category)
4. **Type only** — neither specified (uses first active template matching the type)

### What the User Sees

1. The AI analyzes the conversation and composes the document
2. For **pptx**: a downloadable PowerPoint file appears in the chat as a source attachment
3. For **message**: formatted output appears directly in the chat

### Tips for Best Results

* Have a conversation with analysis/data **before** generating — the AI uses conversation context to build the document
* Use specific requests: "generate a case study summarizing the project above"
* Configure **retrieval instructions** on templates to guide what data the AI gathers
* Configure **output instructions** to control the structure and formatting of the result
* For PPTX, the AI automatically selects appropriate layout types (bullets for lists, tables for data, timelines for chronological content)

## Natural Language Template Detection

Experio automatically detects when a chat message matches an available template category and applies the corresponding template behind the scenes — no special commands needed.

* When a user types something like **"create a case study for Acme Corp"**, the system recognizes the intent matches the **Case Study** category and auto-applies that template's retrieval and output instructions to the generation pipeline.
* If **multiple templates** match the detected category, the assistant asks a follow-up question so the user can choose which template to use.
* If **no category** matches, the message is processed normally without any template behavior.
* This works alongside the **Generate button** — users can either type naturally or use the wand icon. Both paths produce the same template-powered output.
* **No configuration is required.** The system automatically checks all active template categories against incoming messages.
* **PPTX template by name:** "create a pptx using our project strategies template" matches the specific PPTX file by name, even without mentioning the category.
* **New generation in conversation:** Saying "now create a case study from that" starts a new generation request — the system treats it as a fresh query and matches the appropriate template. Follow-up messages that reformat existing output (e.g., "make it shorter") might not trigger template matching.
* **External data + template:** "create a case study based on my latest emails about ManTech" combines template matching with external tool retrieval in a single request.

<Tip>
  Natural language detection only considers **active** categories and templates. Deactivate a category or template to exclude it from automatic matching.
</Tip>

## How PPTX Generation Works

When a user sends `/generate --type pptx --template "name"`:

1. The AI composes slides using the 10 supported layout types
2. For each slide, the system finds the matching layout in the template (case-insensitive)
3. A slide is created from that layout — inheriting its background and master styling
4. Content (title, bullets, tables, charts) is placed programmatically
5. If no matching layout is found, the `blank` layout is used as fallback
6. The final PPTX is returned as a downloadable file
