1. 먼저 앱을 만든다.
https://api.slack.com/start/overview#creating
An introduction to the Slack platform
Slack apps and workflows extend, expand, and automate your Slack workspace. Cultivate conversation, inspire action, and integrate services by building an app or workflow.
api.slack.com
2. Settings-Basic informations-하단의 App level token을 눌러 토큰을 생성한다.
3. 쉘스크립트를 작성한다.
채널 ID는 채널 이름을 클릭 후 하단부를 보면 알 수 있다.
TOKEN="xoxb-~~~"
message=""
curl -H "Content-type: application/json; charset=utf-8" \
--data '{"username": "bot", "channel":"[채널 ID]", "text":"sample message", "attachments": [{"text": '"\"${message}\""'}]}' \
-H "Authorization: Bearer $TOKEN" \
-X POST https://slack.com/api/chat.postMessage
Webhook url로 보내려면 아랫부분의 코드만 갈아끼우면 된다.
webhook_url="https://hooks.slack.com/services/~~~~"
channel=""
message="sample message"
curl -H "Content-type: application/json; charset=utf-8" \
--data '{"username": "bot", "channel":'"\"${channel}\""', "text":"<!channel>", "attachments": [{"text": '"\"${message}\""'}]}' \
-X POST ${webhook_url}
'개발' 카테고리의 다른 글
깃 망한 커밋 없애기 ^*^ git reset upstream main to specific commit (0) | 2022.09.13 |
---|---|
자바 스프링부트 앱- 로그 레벨별로 여러 로그 파일 남기기 (0) | 2022.01.23 |
gcp jupyter notebook에서 url 사용하여 xml 파일 파싱하기 (0) | 2021.11.14 |
코랩 프로+, colab pro plus 요금제 사용기 (6) | 2021.08.16 |
Mongodb에서 특정한 문자열 검색해서 결과물 리턴하기 (0) | 2021.06.10 |