Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
When a VIP user creates an incident, notify a Slack channel (or send via webhook) with a custom JSON message.
Note : You’d need to set up a Slack Incoming Webhook for this.

This business rule triggers on incident creation and checks if the `caller` has the `vips` flag set to `true`. If so, it constructs a JSON payload with incident details and sends a POST request to a predefined Slack webhook URL using `sn_ws.RESTMessageV2`. The purpose is to notify support teams in real time when a VIP user logs an incident.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(function executeRule(current, gSNC, gUser, gSNCSession) {
if (current.caller.vips && current.caller.vips == true) {
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX');
request.setHttpMethod('POST');

var payload = {
"text": " *VIP Incident Created!* \nCaller: " + current.caller.name + "\nNumber: " + current.number + "\nDescription: " + current.short_description
};

request.setRequestHeader("Content-Type", "application/json");
request.setRequestBody(JSON.stringify(payload));
var response = request.execute();
}
})(current, gSNC, gUser, gSNCSession);
Loading