> For the complete documentation index, see [llms.txt](https://docs.rubica.au/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rubica.au/rubica-chat/create-a-word-template-for-ai-assisted-doc-gen.md).

# Create a Word Template for AI-Assisted Doc Gen

Build a Word template for AI-assisted document generation without needing technical knowledge.

## Create a Word Template for AI-Assisted Document Generation

Use this when you want Word to fill in names, dates, tables, images, or whole sections automatically.

You do **not** need to write code.

You only need to build a normal Word document and place the right tags where content should appear.

This is **AI-assisted**, not fully AI-generated.

The template still controls the structure, layout, wording, and rules.

Rubica Chat, or another AI agent, reads the merge fields in the template and fills them with the right content.

{% file src="/files/huV5OxWS3ttVZ57PSRaZ" %}

{% file src="/files/NTAkuq4p9u0ABYnHU0ny" %}

### Why use Word templates

Using Word keeps the document structure intact.

That means you keep the original layout, spacing, tables, page breaks, and section flow.

It also helps preserve document fidelity after the merge.

The final file still behaves like a normal Word document, so it is easier to review and update.

This is useful when someone needs to make final edits after the document is generated.

Word templates also keep anything that should stay fixed in the document.

That includes:

* hardcoded text
* logos and other constant images
* headers and footers
* fonts, colours, and styling
* branded tables and page layouts

The AI only fills the tagged parts.

Everything else stays exactly where you designed it.

{% hint style="info" %}
Think of a tag like a blank label. When the document runs, the engine swaps that tag for real content.
{% endhint %}

### What a template does

A template is a normal `.docx` file with special tags inside it.

For example:

```
Dear {{client_name}},

Your adviser is {{adviser_name}}.
```

When the document is merged, those tags are replaced with real values.

### How AI uses your template

The AI can see:

* every merge field
* the field names
* the document structure
* the rules for sections, tables, images, and repeated content

That means the AI does not invent the whole document from scratch.

It fills the template you designed.

This is why the template matters so much.

Clear field names help the AI understand:

* what belongs in each spot
* which sections are optional
* what kind of answer is expected

### What Rubica Chat does first

When you use Rubica Chat, the agent does not start by writing the document.

It starts by reading the Word template and identifying the merge fields it can populate.

It can then show you what it found before doing the merge.

From there, it can use:

* the earlier conversation
* files you attach
* other connected data sources

It uses that context to decide what belongs in each field.

If needed, it can ask for anything still missing.

#### Typical flow

1. You provide a Word template
2. Rubica Chat reads the template
3. It lists the merge fields, tables, images, and repeat sections it found
4. It uses conversation context, attachments, or connected data to prepare values
5. It confirms what it plans to populate
6. You review that plan and make changes if needed
7. It merges the document using the template structure you created
8. It gives you a download link for the finished Word file

#### Example response

<details>

<summary>Example of what Rubica Chat may show after reading a template</summary>

```
Here's a summary of example_merge_template.docx:

Merge Fields (2 top-level)

IMG:graph — an image field for inserting a graph
prepared_by_name — plain text field for the preparer's name

Row-Repeating Table

TABLE_ROWS:client_names — a table that repeats a row per client, with columns:

client_name, client_DOB, client_mobile, client_email

Column-Repeating Tables (2)

TABLE_COLS:current_funds — columns per fund for current portfolio
TABLE_COLS:proposed_funds — columns per fund for proposed portfolio

Both fund tables share the same row keys per fund column:

admin_fee_flat, balance, investment_fee, orr_levy, product, sliding_admin_fee, total_combined_costs, total_product_costs

Would you like to populate this template with some data, or do something else with it?
```

</details>

This is another reason clear field names matter.

The field list becomes part of the AI's working instructions.

### Review before generating

The agent should confirm what it plans to populate before it generates the document.

This gives you a chance to check the approach before the merge runs.

If something looks off, you can correct it first.

### Improve the output in another pass

You do not need to accept the first result.

If a section is too long, too short, missing context, or not written the way you want, tell the agent what to fix.

Good examples:

* ask it to rewrite one section
* ask it to regenerate a summary
* ask it to use different wording or structure
* ask it to leave some sections unchanged and only update one part

Once the document is generated, Rubica Chat provides a download link to the merged Word file.

You can open that file in Word, review it, and if needed ask the agent to improve certain sections and generate it again.

### Name fields so they make sense

Field names are instructions.

If a field name is clear, the AI is more likely to populate it correctly.

If a field name is vague, the AI has to guess.

#### Good field names

Use names that clearly describe the content.

Examples:

* `{{client_name}}`
* `{{letter_date}}`
* `{{adviser_phone}}`
* `{{AI:executive_summary}}`
* `{{#show_partner_section}}`

#### Poor field names

Avoid names that are too short, unclear, or inconsistent.

Examples:

* `{{name}}`
* `{{date1}}`
* `{{field_a}}`
* `{{summary}}`

#### Field naming tips

* use the same naming style across all templates
* be specific about what the field contains
* use similar names for similar content
* keep section names descriptive

For example, if one template uses `{{client_name}}`, do not use `{{customer_name}}` in another unless the meaning is different.

Consistency makes the templates easier for people to build and easier for AI to understand.

### Help AI match your formatting

AI should usually pick up the right style from the template.

That includes:

* date format
* currency format
* percentages
* names
* headings and paragraph style

#### Dates

For dates, the clearest approach is to signal the format in the field name itself.

This matters because the AI can see the merge field name.

If the field name is vague, the AI has to guess.

If the field name includes the expected format, the AI has a much better chance of getting it right.

Examples:

* `{{letter_date_format_01_Jan_2020}}`
* `{{review_date_format_30_04_2026}}`

Use this approach when the exact date style matters.

Keep the same pattern across the template set.

#### Numbers and amounts

Use field names that tell the AI what kind of value is expected.

Examples:

* `{{super_contribution_percent}}`
* `{{super_contribution_dollar_amount}}`
* `{{portfolio_fee_percent}}`
* `{{insurance_premium_dollar_amount}}`

This is clearer than generic names like:

* `{{super_contribution}}`
* `{{fee}}`
* `{{amount}}`

Use names that distinguish:

* percent vs dollar amount
* annual vs monthly amount
* gross vs net amount

If a value has a specific format requirement, build that clue into the field name.

#### Wording and structure

The AI also learns from nearby text.

If a section should sound formal, keep the heading and surrounding wording formal.

If a field is meant to be a short answer, place it in a short sentence or line.

If a field is meant to contain a longer explanation, give it space and use a descriptive name.

{% hint style="info" %}
The more consistent your template is, the better the AI can follow your intent.
{% endhint %}

### Build your first template

{% stepper %}
{% step %}

### Open a new Word document

Start with a blank document or copy an existing letterhead.
{% endstep %}

{% step %}

### Write the document as normal

Add your headings, paragraphs, tables, and sign-off.

Only leave tags where content should change.
{% endstep %}

{% step %}

### Add simple tags

Use double curly brackets for values that change.

Examples:

* `{{client_name}}`
* `{{letter_date}}`
* `{{adviser_name}}`

Make the names clear and consistent.
{% endstep %}

{% step %}

### Save the file as `.docx`

Do not save as PDF.
{% endstep %}

{% step %}

### Test the template

Run a test merge and check that each tag fills correctly.
{% endstep %}
{% endstepper %}

### The tags you will use most

#### 1. Simple text

Use this for names, dates, titles, addresses, and short values.

```
Client: {{client_name}}
Date: {{review_date}}
Adviser: {{adviser_name}}
```

#### 2. Show or hide a section

Use this when a section should only appear sometimes.

Put the start and end tag on their own lines.

```
{{#show_partner_section}}
Partner name: {{partner_name}}
Partner date of birth: {{partner_dob}}
{{/show_partner_section}}
```

If the section is turned on, the content appears.

If the section is turned off, the whole block disappears.

#### 3. Add a rich content block

Use this when the engine needs to insert a larger section, such as paragraphs or bullet points.

Put the tag on its own line.

```
{{HTML:recommendations_body}}
```

Good uses:

* recommendation sections
* summaries with bullet points
* formatted letters

#### 4. Add an AI-written sentence or paragraph

Use this when the wording will be written for you.

```
Summary: {{AI:executive_summary}}
```

This can sit inside a sentence or on its own line.

#### 5. Add an image

Use this for signatures, charts, or photos.

Put the image tag on its own line.

```
{{IMG:adviser_signature__3cm}}
```

Use a **double underscore** before the width.

Append `__Xcm` to the tag name to set the rendered width.

The height is scaled automatically to match the image's natural shape.

The size hint lives in the template tag, not in the data being merged.

That means the AI or merge process only needs to supply the image URL.

If you do not add a size hint, the engine limits the image to 15.4 cm wide and 8 cm tall.

This works well for most charts.

For smaller images, such as signatures, always include a width hint.

Common sizes:

* signature: `__3cm`
* photo: `__5cm`
* chart: `__15cm`

#### 6. Start a new page

Use this when the next section should begin on a fresh page.

```
{{PAGE_BREAK}}
```

Put it on its own line.

### How to create a repeating table

Use this when you want one Word table row to repeat for each item.

Good examples:

* fee schedules
* product lists
* transactions

#### How to set it up

1. Add a line above the table with `{{TABLE_START:fee_table}}`
2. Create your Word table
3. Put tags in the row you want repeated
4. Add a line below the table with `{{TABLE_END:fee_table}}`

Example:

```markdown
{{TABLE_START:fee_table}}

| Account owner | Fee amount | Frequency |
| --- | --- | --- |
| {{account_owner}} | {{fee_amount}} | {{frequency}} |

{{TABLE_END:fee_table}}
```

{% hint style="warning" %}
The `TABLE_START` and `TABLE_END` tags must be on their own lines, directly above and below the table.
{% endhint %}

### How to create a comparison table

Use this when the left side stays the same, but new columns are added across the page.

Good examples:

* fund comparisons
* product comparisons
* fee comparisons

This tag type is called `TABLE_COLS`. Unlike a repeating row table, `TABLE_COLS` adds a new **column** for each item in the data. Keeping your row labels fixed on the left while the compared options expand to the right.

#### Side-by-side layout (two or more columns)

This is the most common format for a product replacement comparison. The first column contains the row labels. Each additional column represents one product.

#### How to set it up

Build the table with your row labels in the first column. Use the `TABLE_COLS:` tag in the header cell of the data column. Put the individual row field names in the cells below it.

Example:

```
| Fee                  | {{TABLE_COLS:current_funds}} |
| ---                  | ---                          |
| Product              | {{product}}                  |
| Balance              | {{balance}}                  |
| Investment fee       | {{investment_fee}}           |
| Total combined costs | {{total_combined_costs}}     |
```

{% hint style="warning" %}
Only the last column should contain the tags that repeat.
{% endhint %}

**Adding a column type label**

If you want a header row that labels each column as "Current" or "Recommended", include a `column_type` key in each object and add `{{column_type}}` as the first row tag in the template.

#### Example:

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Fee</td><td valign="top">{{TABLE_COLS:replacement_funds_client}}</td></tr><tr><td valign="top"></td><td valign="top">{{column_type}}</td></tr><tr><td valign="top">Product</td><td valign="top">{{product}}</td></tr><tr><td valign="top">Balance</td><td valign="top">{{balance}}</td></tr><tr><td valign="top">Ongoing fees</td><td valign="top"></td></tr><tr><td valign="top">Investment fee</td><td valign="top">{{investment_fee}}</td></tr><tr><td valign="top">Sliding admin fee</td><td valign="top">{{sliding_admin_fee}}</td></tr><tr><td valign="top">Admin fee (flat)</td><td valign="top">{{admin_fee_flat}}</td></tr><tr><td valign="top">ORR levy</td><td valign="top">{{orr_levy}}</td></tr><tr><td valign="top">Total product costs</td><td valign="top">{{total_product_costs}}</td></tr><tr><td valign="top">Total combined costs</td><td valign="top">{{total_combined_costs}}</td></tr></tbody></table>

#### Stacked layout (one product per block)

Use a stacked layout when you have several products to compare and a side-by-side table would be too wide to fit the page comfortably.

Instead of one wide table, each product gets its own two-column block — label on the left, value on the right — stacked vertically.

**How to set it up**

Use a `REPEAT_START` / `REPEAT_END` block wrapping a simple two-column table. Each pass through the repeat block renders one product.

```
{{REPEAT_START:replacement_funds}}

| Fee component        | Value                    |
| -------------------- | ------------------------ |
| Product              | {{product}}              |
| Balance              | {{balance}}              |
| Investment fee       | {{investment_fee}}       |
| Sliding admin fee    | {{sliding_admin_fee}}    |
| Admin fee (flat)     | {{admin_fee_flat}}       |
| ORR levy             | {{orr_levy}}             |
| Total product costs  | {{total_product_costs}}  |
| Total combined costs | {{total_combined_costs}} |

{{REPEAT_END:replacement_funds}}
```

The data format is the same array as the side-by-side layout. The engine renders one full block per object, stacking them down the page.

**When to use each layout**

| Layout                      | Use when                                                                                               |
| --------------------------- | ------------------------------------------------------------------------------------------------------ |
| Side-by-side (`TABLE_COLS`) | Two to four products, comparison is the main purpose, page width allows it                             |
| Stacked (`REPEAT_START`)    | More than four products, portrait layout is too narrow, or products have very different fee structures |

For a standard replacement of product comparison with one current and one recommended fund, side-by-side is usually clearer.

### How to repeat a whole section

Use this when you want to duplicate a full block of content more than once.

Good examples:

* one section per recommendation
* one section per strategy
* one section per person

```
{{REPEAT_START:recommendations}}

{{recommendation_title}}
{{AI:recommendation_rationale}}
{{HTML:recommendation_detail}}

{{REPEAT_END:recommendations}}
```

Everything between those two tags repeats.

### Example template

This is a simple client letter.

```
{{client_name}}
{{client_address}}
{{letter_date}}

Dear {{client_salutation}},

{{HTML:letter_body}}

Kind regards,

{{IMG:adviser_signature__3cm}}
{{adviser_name}}
{{adviser_title}}
```

### Rules that prevent problems

* Use only letters, numbers, and underscores in tag names
* Keep tag names consistent everywhere
* Make tag names clear enough that a person can understand them at a glance
* Use one style for dates, numbers, and amounts across the document
* Put `{{IMG:...}}`, `{{HTML:...}}`, `{{PAGE_BREAK}}`, `{{TABLE_START:...}}`, and `{{TABLE_END:...}}` on their own lines
* Save the file as `.docx`
* Test every new template before using it live

### Common mistakes

#### A tag stays visible in the final document

The tag name may be misspelled.

The value may not have been supplied.

#### A section does not hide properly

The opening and closing tags may not match.

Example:

* correct: `{{#show_partner_section}}`
* correct: `{{/show_partner_section}}`

#### A table does not repeat

The start or end tag may be missing.

They must sit directly above and below the table.

#### An image does not appear

The image link may be broken.

The tag may not be on its own line.

### Simple checklist before you upload

* The document is saved as `.docx`
* Every changing value uses a tag
* Tags are spelled consistently
* Tag names clearly describe the content they expect
* Dates, amounts, and percentages follow one consistent style
* Conditional sections have both start and end tags
* Repeating tables have start and end tags
* Images use `IMG:`
* Large formatted sections use `HTML:`

<details>

<summary>Advanced tag reference</summary>

Use these when you need them:

* `{{field_name}}` — simple value
* `{{#section_name}}` and `{{/section_name}}` — show or hide a block
* `{{HTML:section_name}}` — insert formatted content
* `{{AI:field_name}}` — insert AI-written wording
* `{{IMG:image_name__3cm}}` — insert an image
* `{{PAGE_BREAK}}` — start a new page
* `{{TABLE_START:name}}` and `{{TABLE_END:name}}` — repeat table rows
* `{{TABLE_COLS:name}}` — repeat table columns
* `{{REPEAT_START:name}}` and `{{REPEAT_END:name}}` — repeat a full section

</details>
