TutorialsGenerate Templates with AI

How to Generate FormaMail Templates with AI

You can use AI tools (ChatGPT, Claude, Gemini, etc.) to automatically generate professional FormaMail templates.

By providing the AI with our Schema Reference, it learns exactly how to structure the JSON, which components to use, and how to define dynamic variables.

Prerequisites

  1. An AI Chat Account: ChatGPT Plus, Claude, Gemini Advanced, or similar.
  2. The FormaMail Schema: Use one of these options:

For best results, copy the content from our Template Schema Reference page and paste it into your AI chat, or provide the URL to /llms-full.txt.


Step-by-Step Guide

Step 1: Upload the Schema

Open a new chat with your AI. Either:

Step 2: Copy the “Magic Prompt”

Copy the text block below. This prompt ensures the AI follows our specific JSON structure, particularly the Variables Array format and Page/Section logic.

I am providing you with the technical documentation for FormaMail templates. Please read this carefully to understand the JSON structure, component types, and validation rules.

**YOUR GOAL:**
Generate a valid **[Email / PDF / Excel]** template for: **[INSERT YOUR DESCRIPTION HERE, e.g., A Monthly Subscription Invoice]**.

**STRICT REQUIREMENTS:**

1. **Variables (CRITICAL):**
   - Output the variables definition as a **PLAIN JSON ARRAY** `[...]`.
   - Do NOT wrap variables in an object like `{ "variables": [...] }`.
   - Include `defaultValue` for ALL variables (even required ones) so I can preview the template immediately.
   - Use the unified variable system: Input variables, Constants (`isCalculated: false`), and Calculated Variables (`isCalculated: true`) must all be in this single array.

2. **Template Structure:**
   - If generating an **Email**: Use the `sections` array at the root.
   - If generating a **PDF** or **Excel**: Use the `pages` array at the root.
   - Use descriptive, kebab-case Component IDs (e.g., `invoice-header`, `items-table`).

3. **Components:**
   - Use `rich-text` for all text content (the `text` component is DEPRECATED).
   - Use `table` for data-driven tables from array variables.
   - Use `columns` or `container` for layouts.
   - Use `loop` to iterate over arrays.
   - Use `conditional` for if/else logic.

4. **Output Format:**
   Provide EXACTLY two separate JSON code blocks:
   - Block 1: The Variables JSON (Plain Array).
   - Block 2: The Template JSON (Schema).

Step 3: Customize and Send

Paste the prompt into your chat. Before hitting send, replace the bracketed text with your specific needs.

Example:

“Generate a valid PDF template for a Construction Project Budget that calculates the total cost automatically based on line items and a tax rate constant.”

Step 4: Import to FormaMail

The AI will generate two JSON blocks:

  1. Variables JSON: Copy this into Variables Manager → Raw JSON tab, then click Apply.
  2. Template JSON: Copy this into Schema Editor → Raw JSON tab, then click Apply.

Pro Tips for Better Results

TipExample Prompt
Ask for Math Logic”Create a calculated variable that multiplies quantity by unitPrice for each line item.”
Conditional Content”Show a ‘Past Due’ banner only if status equals ‘overdue’.”
Use System Constants”Add a footer with {{__CURRENT_YEAR__}} and {{__COMPANY_NAME__}}.”
PDF vs ExcelJust change outputFormats to ["excel"] - the structure is identical.
Sample DataSince we require defaultValue, your template will preview immediately.

Troubleshooting

⚠️

Common Issue: AI wraps variables in { "variables": [...] }

Solution: Remind the AI: “Remember, variables must be a PLAIN ARRAY, not wrapped in an object.”

⚠️

Common Issue: Missing defaultValue on variables

Solution: Ask: “Please add realistic defaultValue to ALL variables for preview.”

⚠️

Common Issue: AI uses deprecated text component

Solution: Remind the AI: “Use rich-text instead of text - the text component is deprecated.”


See Also