송용우

Init Slack Webhook

This diff is collapsed. Click to expand it.
......@@ -21,7 +21,9 @@
"koa-router": "^9.0.1",
"mongoose": "^5.9.17",
"morgan": "^1.10.0",
"node-schedule": "^1.3.2",
"path": "^0.12.7",
"slack-client": "^2.0.6",
"slack-node": "^0.1.8",
"voca": "^1.4.0"
},
......
const Slack = require("slack-node"); // 슬랙 모듈 사용
const webhookUri =
'https://hooks.slack.com/services/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';
"https://hooks.slack.com/services/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"; // Webhook URL
const slack = new Slack();
slack.setWebhook(webhookUri);
const send = async (message) => {
slack.webhook(
{
channel: '#general', // 전송될 슬랙 채널
username: 'webhookbot', //슬랙에 표시될 이름
text: message,
},
function (err, response) {
console.log(response);
},
}
);
};
send('안녕');
send("hello");
......