# Notification Templates

<p class="doc-lead">Templates define message content for each channel — <b>Email</b> (subject, HTML body, document links) or <b>WhatsApp</b> (Meta-approved template name and parameters).</p>

<div class="doc-toc">
<p class="doc-toc-title">On this page</p>
<div class="doc-toc-section">
<div class="doc-toc-links">
<a href="#/settings/notification-templates?id=overview">Overview &amp; List View</a>
<a href="#/settings/notification-templates?id=email-fields">Email Template Fields</a>
<a href="#/settings/notification-templates?id=whatsapp-fields">WhatsApp Template Fields</a>
<a href="#/settings/notification-templates?id=actions">Actions</a>
<a href="#/settings/notification-templates?id=faq">FAQ</a>
<a href="#/settings/notification-templates?id=related">Related</a>
</div>
</div>
</div>

<hr class="doc-section-divider">

<h2 id="overview">Overview &amp; List View</h2>

Go to <b>Settings → Notification System → Templates</b>.

<!-- screenshot pending -->

<b>List columns</b>: Id, Name, Template Name, Channel, Provider Type, Priority, Status.

<b>Quick filters</b>: Active Templates (default), WhatsApp Templates, Email Templates.

<b>Filters</b>: Name, Channel, Provider Type, Status.

<b>Header</b>: New.

<b>Row actions</b>: View, Edit, Preview, Activate (when Suspended), Suspend (when Active), Delete (multi).

<hr class="doc-section-divider">

<h2 id="email-fields">Email Template Fields</h2>

Set <b>Provider Type = Email</b> and <b>Channel = Email</b>. WhatsApp-only sections (Template Components, Template Parameters for Meta) are hidden.

<h3>General</h3>

| **Field** | **Description** |
|-----------|-----------------|
| Provider Type * | Email |
| Name * | Internal template name. |
| Channel * | Email |
| Priority | Lower number = higher priority when multiple templates match. |
| Effective From | Optional start date for template validity. |

<h3>Email Content</h3>

| **Field** | **Description** |
|-----------|-----------------|
| Email Subject | Subject line with <code>{{parameterName}}</code> tokens — each token must match a <b>Parameter Name</b> in Template Parameters. |
| Email Body | Rich HTML body with the same <code>{{parameterName}}</code> tokens. |
| Include Document Links | When checked, secure PDF download links are appended to the email body on send. |

<h3>Template Parameters (email)</h3>

| **Field** | **Description** |
|-----------|-----------------|
| Component Type | Body |
| Parameter Name * | Token used in subject/body, e.g. <code>billNumber</code> → <code>{{billNumber}}</code> |
| Field Path * | Dot-notation path on the document, e.g. <code>billNumber</code>, <code>customer.name</code>, <code>date</code>, <code>netTotal</code> |
| Data Type * | String, Number, Currency, Date, etc. — controls formatting |
| Order * | Sort order for parameter resolution |

<p>Field paths are relative to the loaded transaction record — use <code>customer.name</code>, not <code>saleInvoice.customer.name</code>. See the full field reference and examples in <a href="#/features/email-notifications?id=template-parameters">Email Notifications → Template parameters</a>.</p>

<h3>Example email template</h3>

| Field | Example |
|-------|---------|
| Email Subject | Invoice {{billNumber}} from Acme Trading |
| Email Body | Dear {{customerName}},&lt;br&gt;&lt;br&gt;Your invoice {{billNumber}} dated {{billDate}} for {{total}} is ready.&lt;br&gt;&lt;br&gt;Thank you. |
| Template Parameters | billNumber → <code>billNumber</code>; customerName → <code>customer.name</code>; billDate → <code>date</code> (Date); total → <code>netTotal</code> (Currency) |
| Include Document Links | ✓ |

<p>Full guide: <a href="#/features/email-notifications?id=template-setup">Email Notifications → Template setup</a></p>

<hr class="doc-section-divider">

<h2 id="whatsapp-fields">WhatsApp Template Fields</h2>

Set <b>Channel = WhatsApp</b>. Email Content section is hidden.

| **Field** | **Description** |
|-----------|-----------------|
| Template Name (API) * | Exact name approved on Meta / WATI. |
| Language Code * | e.g. en_US — must match approved template. |
| Template Category * | UTILITY, MARKETING, etc. |
| Template Components | Optional header type and buttons matching Meta template. |
| Template Parameters | Map each Meta variable to ERP field paths — see below. |

<h3>Template parameters (WhatsApp)</h3>

| Column | Description |
|--------|-------------|
| Parameter Name | Meta variable identifier — often <code>1</code>, <code>2</code>, <code>3</code> for positional templates matching <code>{{1}}</code>, <code>{{2}}</code> in the approved body. |
| Field Path | Document field path (e.g. <code>customer.name</code>, <code>billNumber</code>, <code>netTotal</code>) — relative to the loaded transaction, not prefixed with transaction type. |
| Component Type | Header or Body (and Button if applicable) — must match Meta template structure. |
| Data Type | String, Currency, Date, etc. — Currency formats to two decimals. |
| Order | Resolution order for the API payload. |

Use <b>Preview</b> to validate WhatsApp parameter resolution.

<p>Full guide: <a href="#/features/whatsapp?id=template-parameters">WhatsApp Messaging → Template parameters</a></p>

<hr class="doc-section-divider">

<h2 id="actions">Actions</h2>

| **Action** | **Description** |
|------------|-----------------|
| New / Edit | Create or change template. |
| Preview | Sample rendered WhatsApp message. For email templates, test with <b>Send Email</b> on an approved document. |
| Activate / Suspend | Enable or disable without deleting. |
| Delete | Remove unused templates — update Transaction Configs first. |

<hr class="doc-section-divider">

<h2 id="faq">FAQ</h2>

<p><b>What placeholders can email templates use?</b></p>
<p>Define <b>Template Parameters</b> with a <b>Parameter Name</b> (used as <code>{{parameterName}}</code> in subject/body) and a <b>Field Path</b> on the document (e.g. <code>billNumber</code>, <code>customer.name</code>, <code>date</code>, <code>netTotal</code>). Test with <b>Send Email</b> on an approved document. Full reference: <a href="#/features/email-notifications?id=template-parameters">Email Notifications → Template parameters</a>.</p>

<p><b>Must WhatsApp templates be approved externally?</b></p>
<p>Yes for WhatsApp Cloud — template names, language, and body structure must match Meta-approved templates exactly.</p>

<p><b>Email vs WhatsApp templates — same record?</b></p>
<p>No. Create separate template records per channel — content rules and length limits differ.</p>

<p><b>Can I suspend a template in use?</b></p>
<p>Suspending blocks new sends referencing the template — update Transaction Configs before deleting.</p>

<p><b>Why is WhatsApp preview empty?</b></p>
<p>Provide sample transaction context on preview when required — some parameters populate only with a real document.</p>

<p><b>Where are templates used for manual email?</b></p>
<p>Link the template on a Transaction Config with <b>Use for Manual Send</b> checked. The <b>Send Email</b> button pre-fills subject and body from this template.</p>

<p><b>Where are templates used for automatic email?</b></p>
<p>Link the template on a Transaction Config with <b>Use for Manual Send</b> unchecked and a Transaction Status trigger. Subject and body are sent from the template when the status change fires — no compose screen.</p>

<p><b>Does Include Document Links attach PDF files?</b></p>
<p>No — it adds secure download links in the email body. Recipients click to open or save the PDF.</p>

<hr class="doc-section-divider">

<h2 id="related">Related Topics</h2>

<ul>
<li><a href="#/features/email-notifications">Email Notifications</a></li>
<li><a href="#/features/whatsapp">WhatsApp Messaging</a></li>
<li><a href="#/settings/notification-providers">Providers</a></li>
<li><a href="#/settings/notification-transaction-configs">Transaction Configs</a></li>
</ul>
