https://api.slack.com/
먼저 Slack에서 자동으로 메시지를 감지할 수 있는 앱을 하나 만들어야 한다.
이건 Slack의 "앱" 기능을 활용한다.
Slack API 페이지에 접속
"Create an App" (앱 만들기) 클릭
"From Scratch" (처음부터 만들기) 선택
앱 이름 입력 (예: Thread Monitor)
설치할 워크스페이스 선택 → "Create App" 클릭
이제 특정 멘션 "cc.내이름"을 감지할 수 있도록 설정.
Slack API에서
"Events API"기능을 활성화하 한다.
Slack API 페이지 → "Event Subscriptions" 클릭
"Enable Events" (이벤트 활성화) 버튼 ON
"Subscribe to bot events" (봇 이벤트 구독) 선택
"message.channels" 추가 (채널에서 메시지 감지 가능)
Request URL 입력 (이건 나중에 설정할 웹훅 주소야)
저장하고, OAuth & Permissions에서 봇 권한 추가 후 "Reinstall App" 실행
Slack에서는 특정 단어
"cc.내이름"이 포함된 메시지를 감지하려면 **"Events API"**와
Python Flask 서버를 활용할 수 있다.
� 아래 코드를 실행하면 특정 멘션이 감지될 때 메시지를 출력할 수 있다.
✅ Google Sheets에 저장하는 코드
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# 구글 시트 인증 (JSON 키 파일 필요)
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("google_sheets_key.json", scope)
client = gspread.authorize(creds)
# 스프레드시트 열기
sheet = client.open("Slack_Archive").sheet1
def save_to_google_sheets(message):
sheet.append_row([message])
✅ Slack에서 앱 생성 →
"Event Subscriptions"에서 "message.channels"권한 추가
✅
Flask 서버 실행
→ 특정 메시지를 감지하는 코드 작성
✅
"cc.내이름" 포함 메시지 필터링
→ 감지된 메시지를 저장하는 코드 추가
✅
Google Sheets에 자동 저장
→ 필요하면 Notion API로도 확장 가능