Amit Gujarathi
Giga Sage
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 02-23-2024 01:06 AM
ServiceNow Slack Integration to Send Slack Messages
Hi All,
In this article we will look into how we can integrate ServiceNow to Slack. We have a usecase to send Salck Notification from ServiceNow whenever the record matches any given condition.
- Create a Rest Message for the Slack API , configuration for which are as given below
- Create a Rest Resource for the same and provide the slack Authorisation details as highlighted on the screenshot
Copy the preview script and Generate a Script include for the same
- Script in the Script include as given below :
var SlackNotificationUtils = Class.create(); SlackNotificationUtils.prototype = { initialize: function() { }, sendSlackNotification : function (channelId,slackMessage) { if (gs.nil(channelId)) { throw 'Channel Id is empty'; } var payload = { "channel": channelId, "text": slackMessage }; try { var r = new sn_ws.RESTMessageV2('Slack Notification for GDPR', 'Post Slack'); r.setRequestBody(JSON.stringify(payload)); var response = r.execute(); var responseBody = response.getBody(); var httpStatus = response.getStatusCode(); var obj = { 'responseBody' : responseBody, 'httpStatus' : httpStatus }; return JSON.stringify(obj); } catch(ex) { var message = ex.message; return JSON.stringify(message); } }, type: 'SlackNotificationUtils' };
- Now we are done with the slack set up
- You can trigger the message to slack using below code for any table and any Slack Channel.
- Syntax for trigger is as given below :
var channelId = <Target Slack Channel name>;
var slackMessage = <Message you wanna share to Slack Channel>;
var response = new SlackNotificationUtils().sendSlackNotification(channelId, slackMessage);
- 2,015 Views
Comments
paragkanoje
Tera Contributor
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
07-01-2025
12:46 PM
Hello @Amit Gujarathi ,
We also have alternate option like below:
If your instance has IntegrationHub and the Slack Spoke, you can automate Slack messages easily:
- Enable Slack Spoke in your ServiceNow instance (requires IntegrationHub).
- Create a Flow in Flow Designer.
- Use the “Post Message” action from the Slack Spoke.
- Configure the action:
- Choose the Slack connection
- Select the channel or user
- Write the message text
- Add trigger conditions (e.g., incident created, updated, etc.).
- Test the flow to confirm messages are being sent.
!!!!!!!!! Don't Heisted to mark helpful if this is expected......
Laveena_A
Tera Contributor
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
07-22-2025
08:07 AM
Hi @paragkanoje
Tried through Integration Hub, it is so easy to configure and it works smooth like a butter 🙂