Slack WebHook 사용하기
7201 단어 Notificationslack-api
목표: 웹페이지에서 Slack으로 메시지 보내기
Slack에게 메시지를 보낼 수있는 Slack WebHook을 사용해보십시오.
준비
작업 공간을 작성하지 않은 경우 새로 작성하십시오.
htps : // s ck. 이 m/c레테테

작업 공간 만들기

채널 만들기

나중에

여기서는 예로 notification 채널


⚙ 마크를 누른 후 앱 추가를 클릭


앱 관리

Start Building

AppName, 작업 공간 지정

CreateApp

Incoming Webhooks

On

채널 선택

허용하다

시간이 가득했습니다.
Slack에게 메시지 보내기

Sample curl request to post to a channel:
에 있는 코드를 복사하여 Terminal에 붙여넣으면 Slack에게 메시지를 날려줍니다.
웹 페이지에서 Slack으로 메시지 보내기
적절한 HTML 파일을 만들어 웹 브라우저에서 열고 POST해 봅니다.

index.html<!DOCTYPE html>
<head>
<title>NotificationTest</title>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
</head>
<body>
<input id="message" type="text">
<button type="button">submit</button>
<script>
$('button').click(function() {
$.ajax({
type: "POST",
url: "https://hooks.slack.com/services/XXXX/XXXX", // Webhook URL を適宜書き換え
data: '{"text":"' + $('#message').val() +'"}',
success: alert('success'),
dataType: 'json'
});
});
</script>
</body>
</html>
이메일이 아니라 Slack에게 알림을 건너뛰고 싶어지는 경우가 많기 때문에, 기억해 두면 앞으로 도움이 될 것입니다.
Reference
이 문제에 관하여(Slack WebHook 사용하기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/yasuken/items/321911387f097b9ffa58
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
<!DOCTYPE html>
<head>
<title>NotificationTest</title>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
</head>
<body>
<input id="message" type="text">
<button type="button">submit</button>
<script>
$('button').click(function() {
$.ajax({
type: "POST",
url: "https://hooks.slack.com/services/XXXX/XXXX", // Webhook URL を適宜書き換え
data: '{"text":"' + $('#message').val() +'"}',
success: alert('success'),
dataType: 'json'
});
});
</script>
</body>
</html>
Reference
이 문제에 관하여(Slack WebHook 사용하기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/yasuken/items/321911387f097b9ffa58텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)