Overview
Event handlers define what happens when an event is raised. Mango by Radix IoT has seven handler types: four built into the core, Email, Set point, Script and Process, and three that come with modules, SNMP, Excel report and Slack message. This guide covers the four core handlers in depth and summarizes the other three.
Handler Types at a Glance
| Handler Type | Action | Common Use |
|---|---|---|
| Sends an email when the event is raised, escalates, or returns to normal | Alert operators and supervisors | |
| Set point | Writes a value to a settable data point | Automated shutdowns, mode changes |
| Script | Runs script callbacks for the event | Complex logic, multi-step responses |
| Process | Runs an operating system command (disabled until enabled in mango.properties) | External integrations, file operations |
| SNMP | Sends an SNMP trap (SNMP module) | Network monitoring integrations |
| Excel report | Runs an Excel report template when the event is raised or returns to normal (Excel Reports module) | Alarm-driven reports |
| Slack message | Posts to a Slack channel (Slack module) | Team chat notifications |
SNMP, Excel report and Slack message appear only when their modules are installed. Slack has its own guide, Configuring Slack Notifications for Mango Alarms.
Creating a Handler
- Open Event Management > Event handlers and choose New (Create event handler)
- Pick the Event handler type and enter a Name
- On the Event types tab, tick the events the handler responds to. One handler can serve many event types, and one event type can have several handlers
- Configure the type-specific settings below, then Save. Disabled switches a handler off without deleting it
You can also start from the Events page: the link in an event's Event handlers column (Handle this event type) opens the Event handlers page for that event type.
Email Handler
The most common handler type. It sends an email when the event is raised, can escalate while the event stays active, and can send a follow-up when it returns to normal.
Configuration
- Choose Email as the Event handler type
- Add Email recipients: Mango users, mailing lists, or email addresses typed in directly
- Choose the Subject line: Include handler name or Include event message. The rest of the subject is fixed: {alarm level} - {name or message} ({notification type}) - id:{event id}
- Optionally add context: Include system information, Include previous point values for point events, Include logfile
- Optionally add Escalation entries, each with an Escalation delay/interval, an Escalation mode (Until inactive (return to normal) or Until acknowledged or inactive (return to normal)), a Maximum emails to send (or Send unlimited emails), and its own Escalation email recipients
- Optionally tick Send inactive email. It goes to everyone who received the active or an escalation email; tick Override inactive recipients to choose different ones
There is no email on acknowledgement; acknowledging an event only stops escalation in the Until acknowledged or inactive mode.
Custom Email Templates
The email body comes from Mango's FreeMarker templates. To change it, provide a Custom email template. The event is available as evt:
${evt.message}: the event message text${evt.alarmLevel}: the alarm level${evt.activeTimestamp}: when the event was raised, in milliseconds; format it with?number_to_datetime${evt.rtnTimestamp}: when the event returned to normal
Prerequisites
Email handlers need working outbound email under Administration > System settings > Email settings; use Send test email there before relying on them. Setting that up is covered in Configuring Event Handlers and Email Alerts.
Set Point Handler
Writes a value to a settable data point when the event is raised and, optionally, when it returns to normal. Used for automated responses.
Configuration
- Choose Set point as the Event handler type
- Choose the Target point. It must be settable
- Choose the Active action, applied when the event is raised: None, Set to point value (copy another point's current value, which must be the same data type), Set to static value (enter the Value to set), or Set to scripted value
- Optionally choose an Inactive action from the same list, applied when the event returns to normal
If the write cannot happen (the target point is missing or not settable, or a copied value has the wrong data type), Mango raises a Set point event handler failure system event naming the cause.
Examples
| Scenario | Target Point | Active Action | Inactive Action |
|---|---|---|---|
| Emergency shutdown on high temp | Equipment Enable (binary) | Static value: false | None (manual restart required) |
| Switch to backup mode | Operating Mode (multistate) | Static value: 2 (Backup) | Static value: 1 (Normal) |
| Open cooling valve on alarm | Valve Position (numeric) | Static value: 100 | Static value: 0 |
Warning
Set point handlers write to real equipment. Test thoroughly in a safe state before deploying automated control actions on production equipment.
Script Handler
Runs script callbacks when the event changes state. Use it for logic that goes beyond a single set-point operation.
Configuration
- Choose Script as the Event handler type and pick a Script engine
- Write the callbacks:
eventRaised(event)andeventInactive(event)are required;eventAcknowledged(event)is optional - Set Script roles (permission groups). The script reads and writes points with these roles
Example Use Cases
- Multi-step shutdown sequence: Disable equipment in a specific order with delays between steps
- Conditional notification: Send different notifications based on time of day or which device alarmed
- Data logging: Write alarm details to an external system or log file
- Calculated response: Read multiple point values to determine the appropriate action
Process Handler
Runs an operating system command on the Mango server. Use it for integrations with external systems.
Warning
The Process handler is disabled by default because it allows remote code execution if the wrong person can configure it. It runs nothing until event-handlers.process.enabled=true is set in mango.properties; until then Mango only logs a warning. Never run Mango as root if you enable it.
Configuration
- Choose Process as the Event handler type
- Enter the Active process command, run when the event is raised, and its Active process timeout (s)
- Optionally enter the Inactive process command, run when the event returns to normal, and its Inactive process timeout (s)
- Use Test command to try a command before saving
To put event details into a command, tick Interpolate commands (access event properties) and use ${event.property}, for example ${event.id} or ${event.alarmLevel}. Interpolation is also off by default and needs event-handlers.process.interpolation-enabled=true in mango.properties. It is the riskier setting, because text from an event message ends up in a shell command.
Example Commands
/usr/local/bin/send_sms.sh +15551234567 "High temp alarm on Gen-1"python3 /opt/scripts/log_alarm.py --event-id ${event.id}(needs interpolation)
Warning
Process handlers run with the same OS permissions as the Mango service account. Limit permissions on the Mango service account and validate all external scripts.
Handler Timing
Each handler type acts at its own points in the event lifecycle:
| Handler | When the event is raised | While it stays active | When it is acknowledged | When it returns to normal |
|---|---|---|---|---|
| Email to recipients | Escalation entries | Stops escalation in Until acknowledged or inactive mode | Optional inactive email | |
| Set point | Active action | — | — | Inactive action |
| Script | eventRaised | — | eventAcknowledged (optional) | eventInactive |
| Process | Active process command | — | — | Inactive process command |
Multiple Handlers per Event
Several handlers can respond to the same event type. A common combination:
- Email handler with an escalation entry (operator now, supervisor after 15 minutes)
- Set point handler (automated safety response)
- Script handler whose
eventInactivedoes logging and cleanup
Testing Handlers
- Use a virtual data source to simulate alarm conditions safely
- Verify email delivery with Send test email first
- For Set point handlers, test against a virtual point before a real equipment point
- Check
ma.logfor handler execution errors
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Email not received | Outbound email not configured, disabled, or unreachable | Use Send test email under Email settings; check the handler's recipients and the spam folder |
| Set point handler doesn't write | Target point missing or not settable, or a copied value of the wrong type | Read the Set point event handler failure system event; fix the target point or action |
| Script handler error | Script error, a missing required callback, or Script roles that cannot reach a point | Check ma.log; check Script roles |
| Process handler does nothing | The handler (or interpolation) is disabled in mango.properties | Look for "Process event handler is disabled" in ma.log |
| Process handler times out | Command runs longer than its timeout | Increase the timeout or optimize the external command |
Tips from the Field
Warning
A script inside a handler (a Script handler, or a Set point handler’s scripted value) runs with the handler’s Script roles, not with the permissions of whoever is logged in. Give those roles access to every point the script reads or sets, and nothing more.
Note
Mango does not include a built-in SMS handler. To send SMS notifications on alarm, either (1) use an SNMP handler to send a trap to an SMS gateway appliance, or (2) use a script handler (for example with the HttpBuilder script utility) or a process handler to call an external SMS API (e.g., Twilio, AWS SNS).
Tip
For complex event response logic that goes beyond what a process handler can do in a single OS command, use a script handler instead. Script handlers can read multiple points, apply conditional logic, and take different actions based on system state, all within a single handler.
Summary
Mango provides seven event handler types: Email, Set point, Script and Process in the core, and SNMP, Excel report and Slack message from modules. Create them under Event Management > Event handlers and tick the event types they respond to. Use email for notifications (with escalation for follow-up), set point for automated control, scripts for complex logic, and process, once deliberately enabled, for external integrations. Combine several handlers on one event type for layered response strategies, and always test handlers safely before deploying to production.