Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

slack-micro

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slack-micro

A micro client to interact with Slack's Web API

Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Slack Micro Client

This is a zero dependency node.js client for Slack's Web API

The goal of this project was to build a node.js client that can be dropped into serverless functions without requiring a massive dependency tree. This client covers two main scenarios: making requests and handling responses.

Install

npm i slack-micro --save

Requests

API

slack('method name or url', {payload}) // returns a promise

Examples

let slack = require('slack-micro');

let message = {
  unfurl_links: true,
  channel: 'C1QD223DS1',
  token: 'xoxb-12345678900-ABCD1234567890',
  text: "I am a test message http://slack.com",
  attachments: [{
    text: "And here's an attachment!"
  }]
}

// send message to any Slack endpoint
slack('chat.postMessage', message).then(result => {
  // Success! The response is in result
});

// respond to webhooks
slack('https://hooks.slack.com/services/T0000/B000/XXXX', message);

Responses

API

// event handler
slack.on('event name', [... 'event name',] callback);

// digester
slack('JSON string' or {message});

Examples

let slack = require('slack-micro');

slack.on('/test', message => {
  // handle the "/test" slash commands
});

slack.on('slash_commands', message => {
  // handle all slash commands
});

slack.on('googlebot', message => {
  // handle the outgoing webhooks trigger word "googlebot"
});

slack.on('googlebot', '/test', 'slash_commands', message => {
  // handle multiple events
});


// AWS Lambda handler
exports.handler = (event, context, callback) => {
  slack(event.body); // parses the body  
}

FAQs

Package last updated on 17 Jul 2016

Did you know?

Socket

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.

Install

Related posts