Skip to main content

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.

  1. Navigate to Profiles -> Device profiles and open your device profile.
  2. Go to the Alarm rules tab and edit your specific alarm rule (e.g., High Temperature).
  3. Scroll down and expand Advanced settings.
  4. 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;
  1. 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.

  1. Navigate to Notification center -> Templates.
  2. Click Create new template.
  3. Set the following basic parameters:
    • Name: Alarm Email Template
    • Type: Alarm
    • Delivery methods: Toggle on Email.
  4. In the Email composition section, set the Subject: ALARM: ${alarmType} - ${alarmOriginatorName}
  5. 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>
  1. 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.

  1. Navigate to Notification center -> Rules and click the + icon to add a new rule.
  2. Trigger: Select Alarm.
  3. Template: Select the Alarm Email Template you just created.
  4. Filters (Optional but Important): If you want emails for all alarm severities, leave the "Alarm severity list" empty. If you accidentally set it to Warning but your device triggers Critical alarms, the email will not send.
  5. Set Notify on to Alarm created.
  6. Under Escalation chain, add your recipients (e.g., your user profile or email address).
  7. 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:

  1. Send a "normal" telemetry value (e.g., 20 for temperature) to clear the active alarm.
  2. Send an "alarm" telemetry value (e.g., 27) to trigger a brand-new alarm.
  3. Check your inbox! You should receive an email with the exact telemetry value and a working button.