feat: Gmail → Apps Script → Worker 입금 알림 연동

- POST /api/bank-notification 엔드포인트 추가
- 하나은행 Web발신 SMS 패턴 파싱 지원
- Gmail message_id 기반 중복 방지
- BANK_API_SECRET 인증 추가
- deposit_transactions 자동 매칭 구현
- 문서 업데이트 (CLAUDE.md, README.md)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-17 00:09:16 +09:00
parent cd33a7c790
commit 9822b28028
7 changed files with 652 additions and 300 deletions

View File

@@ -192,6 +192,7 @@ Telegram Webhook → Security Validation → Command/Message Router
| `index.ts` | Worker 진입점, Email Handler | `fetch()`, `email()` |
| `openai-service.ts` | AI 응답 + Function Calling | `generateResponse()`, `executeFunctionCall()` |
| `summary-service.ts` | 프로필 시스템 | `updateSummary()`, `getConversationContext()` |
| `deposit-agent.ts` | 예치금 에이전트 (Assistants API) | `callDepositAgent()`, `executeDepositFunction()` |
| `security.ts` | Webhook 보안 | `validateWebhook()`, `checkRateLimit()` |
| `commands.ts` | 봇 명령어 | `handleCommand()` |
| `telegram.ts` | Telegram API | `sendMessage()`, `sendTypingAction()` |
@@ -273,9 +274,11 @@ case 'new_tool':
|------|--------|------|
| `SUMMARY_THRESHOLD` | 20 | 프로필 업데이트 주기 (메시지 수) |
| `MAX_SUMMARIES_PER_USER` | 3 | 유지할 프로필 버전 수 |
| `DOMAIN_AGENT_ID` | - | OpenAI Assistant ID |
| `DOMAIN_AGENT_ID` | - | 도메인 관리 Assistant ID |
| `DOMAIN_OWNER_ID` | - | 도메인 관리 권한 Telegram ID |
| `DEPOSIT_AGENT_ID` | - | 예치금 관리 Assistant ID |
| `DEPOSIT_ADMIN_ID` | - | 예치금 관리 권한 Telegram ID |
| `BANK_API_SECRET` | - | 입금 알림 API 인증 키 (wrangler secret) |
---
@@ -285,11 +288,14 @@ case 'new_tool':
|--------|------|-----------|----------|
| Context7 | 문서 조회 | context7.com API | - |
| Domain Agent | 도메인 관리 | OpenAI Assistants | `asst_MzPFKoqt7V4w6bc0UwcXU4ob` |
| Deposit Agent | 예치금 관리 | OpenAI Assistants | `asst_XMoVGU7ZwRpUPI6PHGvRNm8E` |
| Namecheap API | 도메인 백엔드 | namecheap-api.anvil.it.com | 날짜: MM/DD/YYYY → ISO 변환 |
| WHOIS API | WHOIS 조회 | whois-api-eight.vercel.app | ccSLD 미지원 |
| wttr.in | 날씨 | wttr.in | - |
| DuckDuckGo | 검색 | api.duckduckgo.com | - |
| Vault | API 키 관리 | vault.anvil.it.com | - |
| Gmail | 입금 SMS 수신 | deposit.anvil@gmail.com | Apps Script 연동 |
| Apps Script | Gmail → Worker 연동 | script.google.com | 1분마다 실행, message_id 중복 방지 |
---
@@ -302,12 +308,33 @@ case 'new_tool':
매칭 O → confirmed | 매칭 X → pending
[시나리오 2: SMS 먼저]
은행 SMS → Email Worker → 파싱 → bank_notifications 저장
deposit_transactions 검색 (pending)
매칭 O → confirmed + 잔액↑ | 매칭 X → 저장
[시나리오 2: SMS 먼저 - Gmail → Apps Script → Worker]
은행 SMS → Gmail(deposit.anvil@gmail.com) → Apps Script (1분마다)
POST /api/bank-notification
파싱 → bank_notifications 저장
deposit_transactions 검색 (pending)
매칭 O → confirmed + 잔액↑ | 매칭 X → 저장만
```
**Gmail → Worker 연동:**
- Gmail 계정: `deposit.anvil@gmail.com`
- Apps Script: 1분마다 `is:unread 입금` 검색 → Worker API 호출
- 중복 방지: Gmail message_id 기반
**API 엔드포인트:**
```
POST /api/bank-notification
Content-Type: application/json
{
"content": "[Web발신]\n하나,01/16, 23:30\n427******27104\n입금5원\n황병하",
"messageId": "19bc737b3415596a",
"secret": "BANK_API_SECRET 값"
}
```
**입금 계좌:** 하나은행 427-910018-27104 (주식회사 아이언클래드)