
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
browser-node-slack
Advanced tools
A node module for sending and receiving messages with Slack via webhooks that works with browserify.
Slack is a messaging platform that is easy to integrate with. This module should be useful for creating various integrations with Slack, such as chat bots!
node-slack is available via npm:
npm i -S node-slack
Get your custom hook url from Slack by setting up an integration.
var Slack = require('browser-node-slack');
var slack = new Slack('https://hooks.slack.com/services/EXAMPLEHOOK');
If your system requires that requests be made through an HTTP or HTTPS proxy, you can either set an environment variables https_proxy and http_proxy, or pass in the optional second option:
var slack = new Slack(hook_url, {proxy: http_proxy});
To send a message, call slack.send:
slack.send({
text: 'Howdy!',
channel: '#foo',
username: 'Bot'
});
You can also specify an emoji icon, a url to a custom icon, attachments, and any of the other options listed here.
slack.send({
text: 'Howdy!',
channel: '#foo',
username: 'Bot',
icon_emoji: 'taco',
attachments: attachment_array,
unfurl_links: true,
link_names: 1
});
To respond to an outgoing webhook from slack, pass the information from the webhook into slack.respond, along with a callback function responsible for returnign a response.
From inside an Express.js route, this is as easy as passing in req.body:
app.post('/yesman',function(req,res) {
var reply = slack.respond(req.body,function(hook) {
return {
text: 'Good point, ' + hook.user_name,
username: 'Bot'
};
});
res.json(reply);
});
FAQs
Send and receive Slack Webhooks easily! With Browserify!
The npm package browser-node-slack receives a total of 2 weekly downloads. As such, browser-node-slack popularity was classified as not popular.
We found that browser-node-slack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.