슬랙 데스크톱/웹 앱 열기
좌측 사이드바에서 워크스페이스 이름 클릭
"설정 및 관리" → "앱 관리" 선택
"앱 디렉토리 찾아보기" 클릭
검색창에 "Incoming Webhooks" 입력
"Incoming Webhooks" 앱 클릭
"슬랙에 추가" 버튼 클릭
메시지를 보낼 채널 선택 (예: #general, #alerts)
"Incoming Webhook 통합 추가" 클릭
웹훅 URL 복사 (예: https://hooks.slack.com/services/T123/B456/xyz)
# 터미널에서 테스트
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Hello World!"}' \
YOUR_WEBHOOK_URL
https://api.slack.com/apps 접속
"Create New App" 클릭
"From scratch" 선택
앱 이름 입력 (예: "My Bot")
워크스페이스 선택 후 "Create App" 클릭
좌측 메뉴에서 "OAuth & Permissions" 클릭
"Scopes" 섹션에서 "Bot Token Scopes" 찾기
필요한 권한 추가:
페이지 상단의 "Install to Workspace" 클릭
권한 확인 후 "허용" 클릭
"Bot User OAuth Token" 복사 (예: xoxb-123-456-xyz)
슬랙에서 메시지를 보낼 채널 입장
/invite @앱이름 명령어 입력 (예: /invite @My Bot)
// Node.js 예시
const token = "xoxb-your-bot-token";
const channel = "#general";
fetch('https://slack.com/api/chat.postMessage', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel: channel,
text: "Hello from my bot!"
})
});