## Templates

Templates are ready-made message and document content used by business rules and the escalation mechanism. They can include variables that are automatically populated with issue data.

Template management is available under **Configuration → Templates**.

## Template types

| Type | Description | Editor |
|---|---|---|
| Email | HTML email message | HTML code editor with preview |
| SMS | Short text message | Text editor with character counter |
| PDF | PDF document attached to an email | HTML code editor with preview |

The template type is set at creation and cannot be changed afterwards.

## Template settings

- **Template type** — email, sms, or pdf
- **Name** — multilingual template name
- **Description** — multilingual template description
- **Content** — edited separately for each language

For email and PDF templates an additional option **Partial template** is available. Partial templates are fragments embedded inside other templates — they cannot be used on their own.

## Variables

Variable placeholders can be inserted into template content and are automatically substituted during sending. Variables are available through the **Insert keywords** panel in the editor.

### System variables

Format: `{{variable_name}}`

- `{{current_date}}` — current date
- `{{current_time}}` — current time
- `{{logged_first_name}}` — logged-in user's first name
- `{{logged_last_name}}` — logged-in user's last name
- `{{logged_email}}` — logged-in user's email address
- `{{logged_position}}` — logged-in user's position
- `{{logged_phone}}` — logged-in user's phone number

### Issue, customer, and related entity variables

Variables correspond to application fields defined in the system:

- `{{issue_<field_code>}}` — value of an issue field
- `{{customer_<field_code>}}` — value of a customer field
- `{{distributor_<field_code>}}` — value of a distributor field
- `{{service_<field_code>}}` — value of a service field

Special issue variables are also available:
- `{{issue_system_url}}` — link to the issue in the system
- `{{issue_status_url}}` — link to the public status page
- `{{issue_status_link_qr_code}}` — QR code image linking to the status page
- `{{issue_internal_number_barcode}}` — barcode image with the issue number

### Partial templates

Another partial template can be embedded inside an email or PDF template:

The include syntax is generated automatically by the editor when you select a template from the variables panel — no need to type it manually.

The list of available partial templates is shown in the variables panel.

## Starter templates

When creating a template, the **Starter templates** feature is available — ready-made patterns to select as a starting point for editing.

## Where templates are used

- **Issue messages** — when sending an email or SMS from an issue, a template can be selected as the basis for the message content
- **Document generation** — PDF templates enable generating documents (e.g. reports, confirmations) available for download from the issue
- **Business rules** — email and SMS sending actions reference a template; PDF templates can be attached as email attachments
- **Escalations** — each issue type can have an email template assigned for escalation notifications

---

## FAQ

### Can a template contain HTML?
Yes, email and PDF templates support HTML. SMS templates support plain text only.

### How do I preview a template?
The email and PDF editors have a preview mode accessible via the **Preview** tab — the rendered HTML is shown there.

### What is a partial template?
A partial template is a reusable content fragment (e.g. a footer or header) embedded in other templates using the `{% include %}` tag. It cannot be sent on its own.

### Can a template include a QR code or barcode?
Yes. The variables `{{issue_status_link_qr_code}}` and `{{issue_internal_number_barcode}}` generate QR code and barcode images that can be inserted into an HTML template.

### Can the template type be changed after creation?
No. The template type is fixed at creation and cannot be changed.

### How do I know which variables are available?
The full list of variables is shown in the **Insert keywords** panel in the template editor. Variables include issue and customer fields defined in the application fields configuration.
