A template defines the layout and content of the finished document, including tokens for dynamic values. Create the template in Microsoft Word or PowerPoint, upload it to the Document Template model, and use it in a document-generation tool.
For an overview of how document generation works, see Understanding document generation.
Supported file types
| Format | Extension | Best for |
| Word | .docx | Letters, certificates, and forms |
| PowerPoint | .pptx | Presentation decks |
Create a template
- Create the document layout in Microsoft Word or PowerPoint, including any letterhead, logos, tables, and static text.
- Insert tokens wherever dynamic content should appear. A token is a variable enclosed in braces, such as {employee_name} or {date_of_joining}.
Use token names that match the variable names supplied by your agent or workflow. Choose either snake_case or camelCase and use the same naming convention throughout your templates and tool configuration.
Example
An employment certificate might include the following template:
{letter_date} Dear Sir/Madam, This is to certify that {employee_name} is employed by {company_name}. Date of joining: {date_of_joining} Yours sincerely, {signatory_name} |
Best practices for creating templates
| Best practice | Why it matters |
| Type each token as continuous text | Don't apply different formatting within a token. Word can split tokens across formatting boundaries, preventing them from being recognized. |
| Match variable names exactly | Token names must match the names supplied by the document-generation tool. |
| Include branding in the template | Add logos, letterheads, and other static branding directly to the document. |
| Use native Office layout tools | Create tables and layouts using Word or PowerPoint features instead of HTML-based formatting. |
| Test with sample data | Generate a document using known values before publishing the template. |
| Check headers and footers | Tokens in headers, footers, and slide masters are supported. Follow the same continuous-text rule. |
Add tokens
Tokens tell document generation where to insert dynamic values.
Simple tokens
Use a token to insert a single value.
| {employee_name} {designation} |
If no value is available, the token is replaced with blank text.
Loops
Use loops to repeat content for each item in a list.
| {#benefits} - {.} {/benefits} |
Within a loop, {.} represents the current item. If the list contains objects, reference their properties instead.
| {#positions} {title} — {location} {/positions} |
Lists can contain up to 5,000 items. Filter or summarize larger datasets before generating the document.
Conditional sections
Use conditionals to show or hide content.
| {#has_bonus} Annual bonus: {bonus_amount | currency:'USD'} {/has_bonus} |
Use an inverted section to display content only when a value is false.
| {^is_contractor} Permanent employee benefits apply. {/is_contractor} |
Format values
Apply a formatter by adding a pipe (|) after a token.
| {hire_date | date:'long'} {salary | currency:'GBP'} {start_time | time:'short'} {last_updated | datetime:'medium':'short'} {headcount | number:'integer'} {completion_rate | percent:'1dp'} {is_eligible | boolean} {skills | list:'and'} |
Dates, times, numbers, and currency are formatted using the employee's language and regional settings.
Date and time
Use the following styles:
- short
- medium
- long
- full
Calendar dates (YYYY-MM-DD) remain on the same calendar day. Date-time values are adjusted for the employee's timezone.
Numbers
| Style | Example |
| default | Localized number |
| integer | Whole number |
| 1dp / 2dp | Fixed decimal places |
| compact | 15K |
Currency
Currency formatters require a currency code.
| {salary | currency:'GBP'} {salary | currency:'EUR':'code'} |
Display values as a symbol (default), ISO code, or currency name.
Percent
Percent values use ratios.
For example, 0.125 becomes 12.5%.
Boolean
Boolean values are displayed as localized Yes or No.
Lists
Join array values with localized conjunctions.
| Style | Example |
| and | Pension, Healthcare, and Life Assurance |
| or | Passport, Driving License, or National ID |
Automatic formatting
If you declare field types in the document-generation tool, tokens without explicit formatters can be formatted automatically.
| Declared type | Token | Default formatting |
| Date | {hire_date} | Medium date |
| Date and time | {last_login} | Medium date, short time |
| Time | {shift_start} | Short time |
| Boolean | {is_manager} | Yes / No |
| Array | {departments} | Localized list |
Explicit formatters in the template always override automatic formatting.
Unsupported template features
The following template features aren't supported:
| Feature | Example |
| HTML rendering | {%%html ...} |
| Charts | {%%chart ...} |
| Dynamic images | {%image ...} |
| Excel generation | {%xlsx ...} |
| Slide duplication | {%pptxSlide ...} |
| Sub-templates | {%subtemplate ...} |
| QR codes | {%qrcode ...} |
| HTML styling | {%html-styling ...} |
Use standard Word and PowerPoint features, including static images, tables, and layout.