> For the complete documentation index, see [llms.txt](https://docs.buildings.ability.abb/collection/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.buildings.ability.abb/collection/english-v14/academy/twig-templating-in-eliona.md).

# Twig templating in Eliona

## **Introduction to Twig Templating**

Eliona uses [-> \[External Link\] Twig](https://twig.symfony.com/), a powerful and flexible templating engine for JavaScript and PHP, for dynamically generating message content. Twig makes it possible to define templates that are used by external messaging services such as SMS, Google Chat, Slack, or email.

### **Twig.js Version**

The currently implemented version of Twig.js in Eliona is **1.17.1**. The full documentation and implementation notes are available at the following links:

* [-> \[External Link\] Twig.js Repository](https://github.com/twigjs/twig.js)
* [-> \[External Link\] Twig.js Implementation Notes](https://github.com/twigjs/twig.js/wiki/Implementation-Notes)

***

## Twig Syntax and Functions

Twig syntax makes it possible to insert and process dynamic content in templates. Some commonly used functions are:

### **Output variables**

```twig
{{ alarm.val }}  {# Outputs the value of the alarm #}
{{ asset.name }}  {# Displays the name of the affected asset #}
```

### **Use conditions**

```twig
{% if alarm.prio == 1 %}
    Warning: High priority!
{% else %}
    Normal alarm.
{% endif %}
```

### **Use loops**

```twig
{% for tag in alarm.tags %}
    - {{ tag }}
{% endfor %}
```

### **Format strings**

```twig
{{ alarm.message.come.de | upper }}  {# Outputs the alarm text in uppercase #}
```

***

## **Available templates and variables in Eliona**

Eliona offers various template types for different use cases:

* [**Ticket Template**](#ticket-template)
* [**Alarm Template**](#alarm-template)
* [**Password Reset Template**](#passwort-reset-template)
* [**yAxis Formatter Template**](#yaxis-formatter)
* [**Legend Template**](#legend-template)

Each of these templates supports specific variables that are filled dynamically with the respective data.

***

## **Ticket Template**

### **Available variables**

The ticket template can be used to automatically generate ticket notifications. The following variables are available:

```json
{
  "ticket": {
    "ticket_id": "Unique ID of the ticket",
    "parent_id": "ID of the parent ticket, if present",
    "title": "Title of the ticket",
    "description": "Description of the ticket",
    "priority": "Priority of the ticket",
    "reason": "Reason or cause of the ticket",
    "state": "Current status of the ticket",
    "created_by": "Creator of the ticket",
    "created_at": "Creation time of the ticket",
    "assigned_to": "Assigned person or group",
    "assigned_at": "Assignment time",
    "closed_at": "Closing time",
    "proj_id": "Project ID",
    "asset_id": "Asset ID",
    "alarm_id": "Alarm ID, if associated with an alarm",
    "alarm": "Details of the linked alarm",
    "modified_by": "Last editor",
    "modified_at": "Time of the last modification",
    "contact": "Contact information",
    "tags": "List of tags associated with the ticket"
  }
}
```

### **Example of a ticket template**

```twig
New ticket: {{ ticket.title }}

Message:
Ticket ID: {{ ticket.ticket_id }}
Created by: {{ ticket.created_by }}
Priority: {{ ticket.priority }}
Description: {{ ticket.description }}
```

***

## **Alarm Template**

### **Available variables**

The alarm template is based on a test dataset and contains extensive details about alarms and their associated assets.

```json
{
  "alarm": {
    "low": "Lower threshold",
    "high": "Upper threshold",
    "tags": "List of tags associated with the alarm",
    "prio": "Alarm priority level",
    "ack_p": "Indicates whether the alarm must be acknowledged",
    "equal": "Indicates whether an equality check is performed",
    "enable": "Activation status of the alarm",
    "urldoc": "Documentation URL",
    "func_id": "Functional ID of the alarm",
    "msg": "The resolved alarm message,
    "message": {
      "come": {
        "de": "{{asset.name}} ({{alarm.val}})",
        "en": "{{asset.name}} ({{alarm.val}})",
        "fr": "{{asset.name}} ({{alarm.val}})",
        "it": "{{asset.name}} ({{alarm.val}})"
      },
      "gone": "Message when the alarm ends"
    },
    "subject": "Alarm subject",
    "subtype": "Alarm subtype",
    "alarm_id": "Unique alarm ID",
    "asset_id": "ID of the affected asset",
    "attribute": "Affected asset attribute",
    "dont_mask": "Alarm masking status",
    "notify_on": "Notification trigger (e.g. 'R' for reminder)",
    "check_type": "Type of alarm check",
    "created_at": "Alarm creation time",
    "created_by": "Alarm creator",
    "auto_ticket": "Indicates whether a ticket is created automatically",
    "modified_at": "Time of the last modification",
    "modified_by": "Last editor",
    "ts": "Alarm timestamp",
    "val": "Value of the affected parameter",
    "multi": "Multiplier for the alarm value",
    "ack_ts": "Time of acknowledgment",
    "gone_ts": "Time when the alarm disappeared",
    "ack_text": "Acknowledgment text",
    "ack_user_id": "ID of the acknowledging user"
  },
  "locale":"Language and region setting",
  "domain_name": "The domain name of the environment",
  "asset": {
    "ar": "Activation status",
    "gai": "Global asset ID",
    "lat": "Asset latitude",
    "lon": "Asset longitude",
    "name": "Asset name",
    "tags": "List of asset tags",
    "expert": "Expert mode enabled",
    "storey": "Asset floor",
    "urldoc": "Asset documentation URL",
    "proj_id": "Project ID",
    "archived": "Archiving status",
    "asset_id": "Unique asset ID",
    "acl_access": "Access status",
    "asset_type": "Asset type",
    "tracker_id": "Tracker ID",
    "description": "Asset description",
    "acl_permissions": "Access permissions"
  }
}
```

### **Example of an alarm template**

```twig
Alarm for {{ asset.name }}

Message:
The alarm "{{ alarm.message.come.de }}" was triggered.
Attribute: {{ alarm.attribute }}
Value: {{ alarm.val }}
```

***

## User Template

The *User Template* provides access to user-specific information – especially for notification purposes (e.g. email, chat, or alarm forwarding). It can be used in all templates where user data is available.

**Available variables**

```json
"user": {
  "email": "User's email address",
  "user_id": "Unique user ID",
  "lastname": "User's last name",
  "firstname": "User's first name",
  "google_chat": "Google Chat address (optional)",
  "slack": "Slack address (optional)",
  "mail2service": {
    "voice": "Email address for voice notifications (e.g. eCall Voice)",
    "sms": "Email address for SMS notifications (e.g. eCall SMS)"
  }
}
```

### **Example of a user template**

```twig
Notification to: {{ user.firstname }} {{ user.lastname }} ({{ user.email }})

Forward voice alarm to: {{ user.mail2service.voice }}
Forward SMS alarm to: {{ user.mail2service.sms }}

Slack user: {{ user.slack }}
Google Chat: {{ user.google_chat }}
```

***

## **Password Reset Template**

### **Available variables**

The password reset template is used in Eliona to send users an email with a link to reset their password.

```json
{
    "host": "Domain of the environment in which the system is operated",
    "password_reset_token": "Unique token for resetting the password"
}
```

### **Example of a password reset template**

```twig
Hello,  

To reset your password, please click the following link:  

<a href="https://{{ host }}/password-reset/{{ password_reset_token }}">Reset password</a>  

If you did not make this request, you can ignore this email.  

Make sure the link remains unchanged to preserve functionality:  
href="https://{{ host }}/password-reset/{{ password_reset_token }}"
```

{% hint style="warning" %}
Make sure the link remains unchanged to preserve functionality: href="https\://{{host}}/password-reset/{{password\_reset\_token}}"
{% endhint %}

***

## **yAxis Formatter**

The **yAxis Formatter** determines the display of the **axis label** in charts. It displays the current value of the data series together with additional attribute information.

### **Available variables for the yAxis Formatter**

* `{{unit}}` – Unit of the value (e.g. °C, %, kWh)
* `{{value}}` – The current value of the data series
* `{{attribute}}` – Name of the attribute
* `{{gai}}` – Global asset ID
* `{{aggregatedDataField}}` – Data field for the aggregation
* `{{aggregatedDataRaster}}` – Grid with which the data was aggregated
* `{{aggregatedDataType}}` – Type of aggregation (e.g. average, sum)

### **Example of a yAxis Formatter**

```twig
twigCopyEdit{{value}} {{unit}} ({{attribute}})
```

**Result for temperature data:**\
→ `22.5 °C (room temperature)`

***

## **Legend Template**

The **Legend Template** determines the display of the **Legend label** in charts. It describes the data series by combining the name of the asset or data series with attribute information.

### **Available variables for the Legend template**

* `{{unit}}` – Unit of the value (e.g. °C, %, kWh)
* `{{attribute}}` – Name of the attribute
* `{{gai}}` – Global asset ID
* `{{name}}` – Name of the asset or data series
* `{{aggregatedDataField}}` – Data field for the aggregation
* `{{aggregatedDataRaster}}` – Grid with which the data was aggregated
* `{{aggregatedDataType}}` – Type of aggregation (e.g. average, sum)

### **Example of a Legend template**

```twig
{{name}} - {{attribute}} ({{unit}})
```

**Result for a temperature sensor:**\
→ `Air conditioning Office 1 - room temperature (°C)`

***

## **Conclusion**

Twig.js enables flexible and efficient use of templates in Eliona. By using Twig variables and functions, personalized content for tickets, alarms, and emails can be generated. Further information about Twig syntax is available in the official documentation: [-> \[External Link\] Twig.js Wiki](https://github.com/twigjs/twig.js/wiki/Implementation-Notes).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.buildings.ability.abb/collection/english-v14/academy/twig-templating-in-eliona.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
