반응형

Python Slack :

2018/11/03 - [Develop/Python] - Python Slack WebHook (파이썬 슬랙 웹훅) 만들기

2018/11/03 - [Develop/Python] - Python Slack Bot (파이썬 슬랙 봇) - slackclient

2018/11/03 - [Develop/Python] - Python Slack Bot (파이썬 슬랙 봇) - slacker

2018/11/08 - [Develop/Python] - Python Slack Lunch Bot - 점심 알리미 봇

 

SpringBoot Slack :

2018/11/24 - [Develop/Spring Boot] - Spring boot Slack WebHook. 슬랙 웹훅(Java Slack WebHook)

 

 

Node.js 에서 슬랙 웹훅을 사용하는 방법이다.

1. 먼저 아래의 링크에서 슬랙에서 웹훅을 추가하는 방법을 보고온다.

2018/11/03 - [Develop/Python] - Python Slack WebHook (파이썬 슬랙 웹훅) 만들기

 

Python Slack WebHook (파이썬 슬랙 웹훅) 만들기

파이썬으로 슬랙에 메세지를 보낼 수 있는 방법 중 하나인 웹훅(webhook)을 사용하는 방법이다. - Spring boot Webhook (Java Webhook) 2018/11/24 - [Develop/Spring Boot] - Spring boot Slack WebHook. 슬랙 웹..

pangyeon.tistory.com

2. https://api.slack.com/community 슬랙 api 사이트에서 Node.js에서  WebHooks을 사용할 수 있는 api를 찾아본다.

 

이 글에서 사용하는 api는 CoffeScript에 있는 slack-node-sdk 이다.

반응형

3. slack-node-sdk 에 이미 사용방법들을 상세히 설명되어 있다.

 

npm install slack-node --save

를 입력하여 모듈을 설치한다.

 

다음 .js파일을 생성하거나 이미 사용하고 있는 프로젝트에 아래와 같은 코드를 입력하고 실행한다.

 

//slack.js
var Slack = require('slack-node');

webhookUri = "webhookUri를 적는란";

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

slack.webhook({
    channel: "#general",	// 현 슬랙의 채널
    username: "웹훅", // 슬랙에서 보여질 웹훅 이름
    text: "테스트"	//텍스트
}, function (err, response) {
    console.log(response);
});

node slack.js 으로 실행하면 아래와 같이 메세지가 슬랙에 전송된다.

 

 

참고 : https://api.slack.com/community

 

Slack Platform: Community | Slack

Slack developer tools Widely-used open source libraries With hundreds of open source libraries, plugins, and apps covering more than a dozen languages and frameworks, it's tough to know where to begin. Here are some popular libraries supporting a wide rang

api.slack.com

반응형

+ Recent posts