Skip to main content

Create Your First DOCX Template

Transform your firm’s Word precedents into intelligent templates with advanced processing capabilities. Perfect for dynamic documents—contracts, letters, and correspondence that require flexible layouts and complex logic. Using powerful Mustache-like syntax with variables, conditionals, loops, and equations, your AI employees can automatically extract data from evidence files, transcripts, or emails and generate professional documents based on your firm’s exact standards.
DOCX templates work best for documents with dynamic content. Simply delegate the work to your AI employee with source materials, and they’ll extract data and populate your templates using your firm’s precedents and formatting.

Step-by-Step Template Creation

1

Upload Your DOCX Document

Start by uploading your Word document to Odella. Navigate to the Templates section and click “Create New Template,” then select “DOCX Template” and upload your file. Ensure your document is properly formatted and contains the content structure you want to template.
2

Name and Describe Your Template

Give your template a clear, descriptive name and detailed description. This is crucial - your AI employees use this information to determine which template to use in different contexts. Be specific about the document’s purpose, when it should be used, and any special requirements.
3

Edit Document with Mustache Syntax

Enter the template drafting editor where you can modify your document using Mustache syntax to define variables, conditions, loops, equations, and formatting. The syntax uses double curly braces {{ }} as delimiters and allows you to create dynamic content that adapts based on data inputs while maintaining document structure and formatting.
4

Sync Template Fields

After templating your document with Mustache syntax, click “Sync Document” to sync the template fields with the template system. Our AI automatically detects all template variables and generates intelligent instructions for how to fill each field, including data type detection and contextual filling guidance. The system analyzes variable names, surrounding context, and document structure to create appropriate filling instructions.
5

Review and Configure Field Instructions

Review all detected template fields and their auto-generated instructions. You can adjust the prompts to change the tone, set default values, and modify drafting instructions based on your specific requirements. Each field displays its type, current instruction, and preview of how it will be populated. Fine-tune these instructions to ensure the AI understands exactly how to fill each field according to your legal standards and formatting preferences.
6

Save and Publish

When you’re finished configuring all fields and instructions, save and publish your template. The template is now available for use and can be attached directly to an AI employee or integrated into workflows for automated document generation.

Template Syntax Reference

Variables

Insert dynamic values into your template using variable syntax.

Basic Variables

Syntax: {{ variable_name }} Simple variable interpolation replaces the placeholder with the actual value from your data. Variable names should be descriptive and match the data field exactly. Variables are case-sensitive and can include underscores but should avoid spaces. Example: {{ client_name }}, {{ contract_date }}

Transform Pipes

Syntax: {{ variable_name | formatter }} or {{ variable_name | formatter(arg1, arg2) }} Post-process variables with formatters for text transformation, currency formatting, or image embedding. Chain multiple pipes with additional | operators. Available Pipes:
  • lowercase - Converts text to lowercase
  • uppercase - Converts text to uppercase
  • capitalize - Capitalizes the first letter of each word
  • currency(currencyISO, fractionDigits, locale) - Formats as currency (default: USD, 0 decimals, en locale)
  • image(width, height) - Embeds an image from URL with specified dimensions
Example: {{ amount | currency(USD, 2) }}, {{ name | capitalize }}

Conditionals

Control which content appears based on conditions.

Simple Conditionals

Syntax: {{ ? condition }} content {{ / condition }} Conditional sections that only display content when the condition evaluates to true. Perfect for showing different clauses based on client type, agreement terms, or other binary decisions. Example: {{ ? is_corporate }} This is a corporate agreement {{ / is_corporate }}

Inverted Conditionals

Syntax: {{ ^ condition }} content {{ / condition }} Shows content when a condition is false. This is shorthand for {{ if not condition }}. Example: {{ ^ is_premium_client }} Standard terms apply {{ / is_premium_client }}

If/Else Branching

Syntax: {{ if condition }} ... {{ else if condition_b }} ... {{ else }} ... {{ /endif }} Multi-branch conditional sections with explicit if/else if/else logic. Note that {{ ? condition }} is shorthand for {{ if condition }} and {{ ^ condition }} is shorthand for {{ if not condition }}. Close blocks with {{ /endif }}. Example: {{ if is_corporate }}Corporate{{ else if is_nonprofit }}Nonprofit{{ else }}Individual{{ /endif }}

Loops

Iterate through lists and arrays to generate repeating content. Syntax: {{ # items }} {{ item_value }} {{ / items }} Iteration blocks that repeat content for each item in a list or array. The opening tag {{ # items }} starts the loop, and the closing tag {{ / items }} ends it. Everything between these tags will be repeated for each item in the collection. Inside the loop, you can access properties of each item directly. Example: {{ # witnesses }} {{ name }}, {{ title }} {{ / witnesses }} Special Variables:
  • {{ loop_index }} - Provides automatic numbering starting from 1

Equations

Compute values inline using arithmetic and function expressions. Syntax: {{= expression }} Evaluates arithmetic or function expressions. Reference variables using bracket notation [variable_name]. Basic arithmetic operators (+, -, *, /, %, ^) and parentheses are supported. Example: {{= 1 + 1 }}, {{= SUM([amounts]) }}, {{= ROUND([amount] * [tax_rate], 2) }}
Variables in equations must be wrapped in square brackets: [amount], [tax_rate], [prices].

Supported Equation Functions

Aggregation Functions
  • SUM(…numbers) - Adds all numbers. Example: {{=SUM([prices])}}
  • AVERAGE(…numbers) - Returns arithmetic mean. Example: {{=AVERAGE([scores])}}
  • COUNT(…values) - Counts numbers in arguments. Example: {{=COUNT([items])}}
  • MAX(…numbers) - Returns largest value. Example: {{=MAX([prices])}}
  • MIN(…numbers) - Returns smallest value. Example: {{=MIN([prices])}}
  • SUMPRODUCT(…arrays) - Multiplies corresponding array components and sums. Example: {{=SUMPRODUCT([quantities], [prices])}}
  • PRODUCT(…numbers) - Multiplies all numbers. Example: {{=PRODUCT([width], [height], [depth])}}
Rounding Functions
  • ROUND(number, digits) - Rounds to specified digits (default 0). Example: {{=ROUND([amount], 2)}}
  • CEILING(number, significance) - Rounds up to nearest multiple (default 1). Example: {{=CEILING([amount], 5)}}
  • FLOOR(number, significance) - Rounds down to nearest multiple (default 1). Example: {{=FLOOR([amount], 5)}}
Math Functions
  • ABS(number) - Returns absolute value. Example: {{=ABS([balance])}}
  • SQRT(number) - Returns square root. Example: {{=SQRT([area])}}
  • POWER(number, power) - Raises to power. Example: {{=POWER([base], 2)}}
  • MOD(number, divisor) - Returns remainder from division. Example: {{=MOD([total], 10)}}
Text Functions
  • CONCATENATE(…text) - Joins text strings. Example: {{=CONCATENATE([first_name], " ", [last_name])}}
  • LEFT(text, numChars) - Returns first N characters (default 1). Example: {{=LEFT([code], 3)}}
  • RIGHT(text, numChars) - Returns last N characters (default 1). Example: {{=RIGHT([code], 4)}}
  • LEN(text) - Returns string length. Example: {{=LEN([description])}}
  • UPPER(text) - Converts to uppercase. Example: {{=UPPER([name])}}
  • LOWER(text) - Converts to lowercase. Example: {{=LOWER([email])}}
Logical Functions
  • IF(condition, trueValue, falseValue) - Returns value based on condition. Example: {{=IF([is_premium], [price] * 0.9, [price])}}

Comments

Syntax: {{! comment text }} Comment blocks that are ignored during template processing and won’t appear in the final document. Use these for documentation, notes to other template editors, or temporary removal of content. Example: {{! This section handles payment terms }}

Advanced Template Configuration

Variable Types

Configure different data types for variables including text, dates, numbers, and boolean values. Set formatting requirements and validation rules for each variable type.

Conditional Logic

Create smart conditional sections that show or hide content based on data values, such as different clauses for different contract types or client categories.

Dynamic Lists

Use loop syntax to handle dynamic lists of items like witnesses, terms, payment schedules, or any repeating data structures in your documents.

Default Values

Set intelligent default values for common fields and define fallback content when optional data is not provided.

Best Practices

1

Descriptive Variable Names

Use clear, descriptive variable names like {{ client_full_legal_name }} rather than generic names like {{ name1 }}. This helps with AI understanding and template maintenance. Consider using naming conventions like entity_type, agreement_date, billing_address_line1 to create consistency across your templates.
2

Logical Content Structure

Organize your template with logical sections and use comments to document complex conditional logic or loops for future reference and maintenance. Group related variables together and use whitespace effectively to make your template code readable.
3

Comprehensive Field Instructions

Provide detailed instructions for each template field, including formatting requirements, tone preferences, and any special considerations for AI population. Specify whether fields should be formal or casual, how dates should be formatted, and any legal language requirements.
4

Regular Testing

Test your templates with sample data to ensure all variables, conditions, and loops work correctly before publishing to production use. Test edge cases like empty lists, missing optional fields, and different data combinations to ensure robust template behavior.

Using Your DOCX Template

Once published, your AI employees can use this template to generate documents automatically:

Delegate via Email, Chat, or Slack

Simply send a message: “Draft the service agreement for Acme Corp using the attached proposal.” Your AI employee extracts the data and generates the document.

Batch Document Generation

Generate one document or multiple. “Create engagement letters for all 25 new clients in the attached spreadsheet” - completed in seconds.

AI Employee Integration

Assign templates to specific AI employees based on their role. They automatically select the right template and populate all variables based on context and source materials.

Workflow Integration

Integrate templates into custom workflows using the “Populate Template” block. Templates can be triggered by specific events, data changes, or user actions.

Example Delegation

You: “Draft the client engagement letter for Acme Corp using the details from our email thread and the attached proposal” AI Employee:
  • Extracts relevant information from emails and proposal
  • Selects the appropriate Word template
  • Populates all variables, handles conditional logic, and performs calculations
  • Generates a professional document using your firm’s exact formatting and language
  • Delivers the completed document ready for your review
For detailed instructions on how to use your published templates with AI employees and workflows, see our Using Templates guide.

Template Examples

Below are real-world template patterns with detailed explanations to help you build sophisticated documents.

Variable Examples

Simple Variable Insertion

Dear {{ client_name }},
This replaces {{ client_name }} with the actual client’s name from your data. The variable name should exactly match the field name in your data source.

Transform Pipe Examples

Basic Text Formatting:
Company: {{ company_name | uppercase }}
Email: {{ email | lowercase }}
Client Name: {{ full_name | capitalize }}
Currency Formatting:
Total: {{ amount | currency(USD, 2, en) }}
Price: {{ price | currency(EUR, 2, de) }}
Balance: {{ balance | currency(GBP, 0, en-GB) }}
Chaining Multiple Pipes:
{{ company_name | lowercase | capitalize }}
This first converts to lowercase, then capitalizes each word. Image Embedding:
{{ company_logo | image(300, 150) }}
Embeds the image at 300px width and 150px height.

Conditional Examples

Simple Conditional Logic

{{ ? is_individual }} 
acting in their individual capacity 
{{ / is_individual }}
{{ ? is_corporate }} 
acting through its duly authorized representatives 
{{ / is_corporate }}
This creates mutually exclusive content blocks. Only one section will appear based on the client type.

If/Else/Else If Chain

{{ if is_individual }}
acting in their individual capacity
{{ else if is_corporate }}
acting through its duly authorized representatives
{{ else }}
acting as applicable
{{ /endif }}
Equivalent branching using explicit if/else if/else with a closing {{ /endif }}.

Inverted Conditions

{{ ^ is_premium_client }}
Standard terms and conditions apply.
{{ / is_premium_client }}
This content only appears for non-premium clients.

Conditional Formatting

Total Amount: {{ ? currency_symbol }}{{ currency_symbol }}{{ / currency_symbol }}{{ amount }}{{ ? is_estimate }} (estimated){{ / is_estimate }}
This shows how to conditionally include formatting elements like currency symbols and qualifiers.

Loop Examples

Simple List Iteration

Witnesses:
{{ # witnesses }}
{{ loop_index }}. {{ name }} ({{ title }}){{ ? address }}, residing at {{ address }}{{ / address }}
{{ / witnesses }}
This creates a numbered list of witnesses with optional address information. The loop_index provides automatic numbering.

Nested Conditional Lists

{{ ? has_attachments }}
Attachments:
{{ # attachments }}
- {{ filename }}{{ ? description }}: {{ description }}{{ / description }}
{{ / attachments }}
{{ / has_attachments }}
This shows how to combine conditionals with loops - only showing the attachments section if attachments exist.

Equation Examples

Basic Equations

{{=1 + 1}}
{{=SUM([line_items])}}
{{=ROUND([amount] * [tax_rate], 2)}}
{{=IF([is_discounted], [amount] * 0.9, [amount])}}
{{=CONCATENATE("Total: $", ROUND(SUM([prices]), 2))}}
{{=SUMPRODUCT([quantities], [unit_prices])}}
{{=AVERAGE([scores]) * 100}}

Loops with Equations

You can combine loops with equations to display lists and calculate totals. Use dot notation [array.property] to access nested properties within arrays when using equations:
Assets:
{{#assets}}
Item {{idx}}: {{value}}
{{/assets}}

Total Asset Value: {{=SUM([assets.value])}}
This example loops through an assets array to display each item, then uses {{=SUM([assets.value])}} to calculate the total of all value properties in the array.

Complex Invoice Example

Line Items:
{{#line_items}}
- {{description}}: ${{price}} x {{quantity}} = ${{=ROUND([price] * [quantity], 2)}}
{{/line_items}}

Subtotal: ${{=SUM([line_items.total])}}
Tax ({{tax_rate}}%): ${{=ROUND(SUM([line_items.total]) * [tax_rate] / 100, 2)}}
Grand Total: ${{=ROUND(SUM([line_items.total]) * (1 + [tax_rate] / 100), 2)}}
Equations can be nested and combined. For example: {{=ROUND(SUM([amounts]) * [tax_rate], 2)}} calculates the sum of amounts, multiplies by tax rate, and rounds to 2 decimal places.

Comment Examples

{{! Payment terms section - modify based on client credit rating }}
Payment Terms: {{ payment_terms }}
{{! TODO: Add late fee calculation formula }}
Use comments to document business logic, remind about future updates, or explain complex template sections to other team members.
Strong governance plans should include reviewing AI-generated documents, especially for business-critical functions. Test all template variables, conditions, and loops thoroughly before publishing. Pay special attention to conditional logic to ensure all possible data combinations produce valid documents.
Ready to create your first DOCX template? Transform your firm’s precedents into intelligent, AI-powered document generation tools that your AI employees can use to extract data from any source and generate professional documents with dynamic content in seconds!