Unsubscribe Notification Trigger (Advanced Trigger)

Last Updated: 17/4/2024     Tags: trigger, triggers, advanced, js, javascript
  • Switch Version
  • V5
  • V4

To send unsubscribe notifications, create a trigger with a blank Matches field, an Events field containing only u.

st=>start: Event e=>end: End op1=>operation: Send Notification Email st(right)->op1(right)->e

JS Code

Simply create a notification list with the desired recipients, and insert that list's ID as the value of the notify_list_id variable in this code:

var tm = require('tm');

exports.handler = function (event){
    var notify_list_id = 1,
        msg = tm.escape(event.subscriber.email) + " has unsubscribed via '" + tm.escape(event.activity.name) + "'. Please ensure this request is actioned within 5 business days.";
    tm.notify({
        tag: "Unsubscribe",
        description: event.subscriber.email,
        body_text: msg,
        body_html: msg,
        status: "neutral"
    }, notify_list_id);
}

Reference

For more information about advanced triggers, see the Advanced Trigger Reference.