How to Set Up Notifications
This guide will walk you through attaching live telemetry data to your alarms and creating a professional HTML email template with an actionable button.
Step 1: Device Profile
By default, the Notification Center cannot directly read live telemetry data. We must save the telemetry value into the alarm's "Details" when the alarm is created.
- Navigate to Profiles -> Device profiles and open your device profile.
- Go to the Alarm rules tab and edit your specific alarm rule (e.g., High Temperature).
- Scroll down and expand Advanced settings.
- In the Additional info field, clear any existing text and paste the following JavaScript code:
var details = {};
// Replace 'temperature' with your actual telemetry key (e.g., 'humidity') if needed
if (typeof temperature !== 'undefined') {
details.data = temperature;
}
return details;
- Click the blue checkmark to save the editor, then click Save on the device profile.
Step 2: Create the HTML Email Template
Now we will create the visual layout of the email.
- Navigate to Notification center -> Templates.
- Click Create new template.
- Set the following basic parameters:
- Name:
Alarm Email Template - Type:
Alarm - Delivery methods: Toggle on
Email.
- Name:
- In the Email composition section, set the Subject:
ALARM: ${alarmType} - ${alarmOriginatorName} - In the Message section, open the Source code editor (click the
<>icon) and paste this HTML:
<p>Warning, an alarm has been triggered on device <b>${alarmOriginatorName}</b>.</p>
<ul>
<li>Current value: <b>${data} °C</b></li>
</ul>
<br>
<div style="text-align: left;">
<a href="[https://app.hardwario.cloud/alarms](https://app.hardwario.cloud/alarms)"
style="background-color: #0085CC; color: white; padding: 12px 25px; text-decoration: none; border-radius: 4px; font-weight: bold; display: inline-block;">
OPEN ALARMS DASHBOARD
</a>
</div>
<br>
<p><i>This email was automatically generated by ThingsBoard.</i></p>
- Click Save.
(Notice how we use
${data}—this perfectly matches the variable we created in Step 1).
Step 3: Create the Notification Rule
Finally, we need to tell the system when to send this email and to whom.
- Navigate to Notification center -> Rules and click the + icon to add a new rule.
- Trigger: Select
Alarm. - Template: Select the
Alarm Email Templateyou just created. - Filters (Optional but Important): If you want emails for all alarm severities, leave the "Alarm severity list" empty. If you accidentally set it to
Warningbut your device triggersCriticalalarms, the email will not send. - Set Notify on to
Alarm created. - Under Escalation chain, add your recipients (e.g., your user profile or email address).
- Click Add or Save.
Step 4: How to Test Properly
If an alarm is already "Active" in ThingsBoard, sending the same high value again will not trigger a new email.
To test your new setup:
- Send a "normal" telemetry value (e.g.,
20for temperature) to clear the active alarm. - Send an "alarm" telemetry value (e.g.,
27) to trigger a brand-new alarm. - Check your inbox! You should receive an email with the exact telemetry value and a working button.