Skip to content

feat(portfolio): Slack 사진 업로드 → 포트폴리오 초안 자동 등록 봇 - #49

Merged
brekarta-stack merged 4 commits into
mainfrom
brekarta-stack/포트폴리오-자동-업로드-봇-만들기
Nov 3, 2026

Hidden character warning

The head ref may contain hidden characters: "brekarta-stack/\ud3ec\ud2b8\ud3f4\ub9ac\uc624-\uc790\ub3d9-\uc5c5\ub85c\ub4dc-\ubd07-\ub9cc\ub4e4\uae30"
Merged

brekarta-stack merged 4 commits into
mainfrom
brekarta-stack/포트폴리오-자동-업로드-봇-만들기

Conversation

@brekarta-stack

Copy link
Copy Markdown
Owner

무엇

Slack 채널에 완성품 사진을 올리면(파일명 고객명-YYMMDD-명칭 (n).jpg) 파일명에서 고객·제작 시기·명칭을 읽고, Claude 가 사진을 보고 제목·요약·본문·alt 를 써서 비공개 초안으로 등록한다. 결과는 그 메시지 스레드에 답글(어드민 편집 링크)로 달린다. 공개는 사람이 어드민에서 켠다.

구조

  • POST /api/slack/events — Slack Events API 수신. 서명 검증 → 3초 안에 200 → after() 로 처리. 재전송은 사유(http_timeout)로 구분.
  • POST /api/portfolio/intake — x-webhook-secret 인증(blog/publish 와 같은 패턴). 봇과 CLI 가 같이 쓰는 뒷단. GET ?probe=1 로 설정 상태 확인.
  • src/lib/portfolio-intake.ts 순수 규칙(파싱·묶기·프롬프트·규격화), portfolio-intake-flow.ts 의존성 주입 흐름(테스트 대상), portfolio-intake-run.ts 실제 구현(sharp·Supabase·Claude).
  • 같은 묶음이 또 오면 기존 초안에 사진만 덧붙인다(식별자 airtable_id = intake:<키>). 동시 요청 대비 "자리 먼저 잡기" + 부분 갱신, 유니크 인덱스 마이그레이션 동봉.
  • scripts/portfolio-intake.mjs — 시험 운전·수동 등록용 CLI.

배포 후 필요한 것 (코드만으로는 동작하지 않음)

Vercel production env: PORTFOLIO_INTAKE_SECRET, ANTHROPIC_API_KEY, SLACK_SIGNING_SECRET, SLACK_BOT_TOKEN (선택 SLACK_PORTFOLIO_CHANNEL_ID). Slack 앱은 docs/slack-portfolio-bot-manifest.json 으로 생성. 절차 전체는 docs/portfolio-intake-bot.md.

검증

  • npm test 277건 통과(신규 36건: 파일명 파싱, 묶기, 규격화, 흐름(가짜 의존성), Slack 서명·필터·허용 호스트, sharp 실처리, CLI 청크)
  • tsc --noEmit, eslint, next build(더미 env) 통과
  • 별도 컨텍스트 리뷰 1회 → 중요 지적 5건(공개 항목 덧붙임, 중복 초안, 타임아웃, SSRF, 크기 검사) 반영 후 재검증 중

🤖 Generated with Claude Code

- POST /api/slack/events: Slack Events API receiver (signature check,
  respond 200 then process in after(), retry-reason aware, host allowlist)
- POST /api/portfolio/intake: webhook-secret endpoint shared by the bot
  and the CLI; GET probe reports which env vars are missing
- Filename rule "고객명-YYMMDD-명칭 (n).jpg" groups photos into one case;
  Claude writes title/summary/description/alts (JSON schema output);
  saved as a draft (published=false), same key appends to the draft,
  published cases are refused unless publish is explicit
- Claim-first placeholder row + partial update on finalize so concurrent
  per-photo Slack messages do not create duplicate drafts or clobber
  admin edits; unique index migration for the intake key
- scripts/portfolio-intake.mjs for trial runs and manual batches
- docs/portfolio-intake-bot.md + Slack app manifest; 36 tests

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
actioncraft-web Ready Ready Preview Nov 3, 2026 6:58am UTC

Request Review

…uest

- finalize: optimistic lock on updated_at with re-read and retry, so two
  concurrent per-photo uploads no longer drop each other's images
- discard a claimed placeholder only if it is still empty (another request
  may have filled it in the meantime)
- process at most 3 groups per request so generation stays within the
  300s function limit; extra groups are reported, not silently dropped
- tests for both paths (38 total)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…자동-업로드-봇-만들기

# Conflicts:
#	package-lock.json
#	src/app/api/admin/migrate/route.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brekarta-stack
brekarta-stack merged commit bf6f03a into main Nov 3, 2026
2 of 3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 67a9c92c Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant