• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

slack.com, slack, node sdk

slack-node-sdk

Build Status

Slack Node SDK, full support for Webhook and the Slack API, continuously updated.

Install

npm install slack-node

Slack Webhook usage

At first, you have to apply Slack webhook. and copy webhook url

Webhook usage

Code example:

var Slack = require('slack-node');

webhookUri = "__uri___";

slack = new Slack();
slack.setWebhook(webhookUri);

slack.webhook({
  channel: "#general",
  username: "webhookbot",
  text: "This is posted to #general and comes from a bot named webhookbot."
}, function(err, response) {
  console.log(response);
});

Use icon emoji, you can give a Slack defined emoji, or use image from URL.

var Slack = require('slack-node');

webhookUri = "__uri___";

slack = new Slack();
slack.setWebhook(webhookUri);

// slack emoji
slack.webhook({
  channel: "#general",
  username: "webhookbot",
  icon_emoji: ":ghost:",
  text: "test message, test message"
}, function(err, response) {
  console.log(response);
});

// URL image
slack.webhook({
  channel: "#general",
  username: "webhookbot",
  icon_emoji: "http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png",
  text: "test message, test message"
}, function(err, response) {
  console.log(response);
});

Otherwise, you can check usage from example

Slack API support

First you have to apply an API from SLACK API page,

The method, please reference Slack API page

example code,

var Slack = require('slack-node');
apiToken = "-- api token --";

slack = new Slack(apiToken);

slack.api("users.list", function(err, response) {
  console.log(response);
});

slack.api('chat.postMessage', {
  text:'hello from nodejs',
  channel:'#general'
}, function(err, response){
  console.log(response);
});

Changelog

  • 0.1.7

  • slack-node no longer crashes if Slack returns HTML instead of JSON.

  • 0.1.6

  • support ES6, promise function.

  • 0.1.3

  • use requestretry replace request. thanks for timjrobinson

  • update test

  • fixed emoji error

  • fixed return error crash when run time.

  • 0.1.0

  • fixed test type error

  • support new slack webhook.

  • 0.0.95

  • fixed webhook function and test

  • support file upload function

  • 0.0.93

  • return header and status

  • 0.0.92

  • merge slack emoji for webhook

  • pass request full request object

  • 0.0.9

  • pass parameters bug fixed

More Repositories

1

frontend-test-all-the-way

前端測試實戰教學 - 從今天開始進行前端測試
HTML
26
star
2

simple-livereload

simeple livereload
JavaScript
17
star
3

iloveck101

ck101 downloader Node.js version, save your time, and fullfill your harddisk.
JavaScript
13
star
4

sails-talk-demo

Quick demo, use Angular.js and Sails.js to build a realtime chatroom app.
JavaScript
12
star
5

module-loader

express, module auto loader
JavaScript
10
star
6

angular-express

angular and express in brunch
JavaScript
10
star
7

We_Have_No_Moat

7
star
8

machine_learning_awesome_zh

deep learning and machine learning
7
star
9

sails-new-starter-toolkit

sails.js, new starter for sass, jade. A new toolkit
HTML
7
star
10

QRLoing_reproduce

login by QRCode with mobile scan flow reproduce
JavaScript
7
star
11

beauty-scraper

scrap image from http://www.aio.com.tw/wall
JavaScript
6
star
12

ser-node

ser-node
CoffeeScript
6
star
13

node-module-example

node modules collections for personal usage.
JavaScript
3
star
14

ydl

youtube download library
JavaScript
3
star
15

Javascript-OO-Practice

Javascript OO practice from website informations.
JavaScript
3
star
16

sails-hackathon-starter

CSS
2
star
17

livereload-node

livereload node.js version
JavaScript
2
star
18

node-demo

node.js app demo
JavaScript
2
star
19

webPos

JavaScript
2
star
20

fig-node

fig, a docker tool, for quick runs web, database ... this is node.js server example.
JavaScript
2
star
21

rest-client

connect to other RESTful service
JavaScript
2
star
22

newbie-web-developer

technology for newbie for web developers
2
star
23

chatbot-basic-course

1
star
24

xlp

xlp
Shell
1
star
25

sails-hook-autoreload-extend

JavaScript
1
star
26

guess-number

a node.js application - guest number total
JavaScript
1
star
27

parcel-react-app

JavaScript
1
star
28

hubadmin_panel

HTML
1
star
29

try-book

a gitbook try and error example
1
star
30

jquery_to_react

example include mixed, module, call jQueryUI
HTML
1
star
31

khbus

Taiwan Kaohsiung bus API - node.js client version.
JavaScript
1
star
32

generator-sails-coffee

sails.js coffeescript style, yeoman generator
CoffeeScript
1
star
33

socket-server

cluster, socket.io server / client distribution server structure
JavaScript
1
star