Skip to content

Instantly share code, notes, and snippets.

@deckerego deckerego/slack.js
Created Sep 14, 2018

Embed
What would you like to do?
Send a Message to Slack
'use strict';
const https = require('https');
class Slack {
constructor(slackPath) {
this._options = {
hostname: "hooks.slack.com",
method: "POST",
path: slackPath,
};
}
sendSlack(message) {
const payload = JSON.stringify({
text: message,
});
const req = https.request(this._options);
req.on("error", (error) => console.log("Error in sending Slack message: ", JSON.stringify(error)));
req.write(payload);
req.end();
}
}
module.exports = Slack;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.