Initial implementation of Telegram AI customer support bot

Cloudflare Workers + Hono + D1 + KV + R2 stack with 4 specialized AI agents
(onboarding, troubleshoot, asset, billing), OpenAI function calling with
7 tool definitions, human escalation, pending action approval workflow,
feedback collection, audit logging, i18n (ko/en), and Workers AI fallback.

43 source files, 45 tests passing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-02-11 13:21:38 +09:00
commit 1d6b64c9e4
58 changed files with 12857 additions and 0 deletions

63
wrangler.toml Normal file
View File

@@ -0,0 +1,63 @@
name = "telegram-ai-support"
main = "src/index.ts"
compatibility_date = "2024-01-01"
[ai]
binding = "AI"
[vars]
ENVIRONMENT = "production"
# AI Gateway 경유
OPENAI_API_BASE = "https://gateway.ai.cloudflare.com/v1/d8e5997eb4040f8b489f09095c0f623c/telegram-ai-support/openai"
# D2 렌더링 서비스 (jp1 Incus)
D2_RENDER_URL = "http://10.253.100.107:8080"
# 외부 API
NAMECHEAP_API_URL = "https://namecheap-api.anvil.it.com"
WHOIS_API_URL = "https://whois-api-kappa-inoutercoms-projects.vercel.app"
CLOUD_ORCHESTRATOR_URL = "https://cloud-orchestrator.kappa-d8e.workers.dev"
[[d1_databases]]
binding = "DB"
database_name = "telegram-ai-support"
database_id = "REPLACE_WITH_ACTUAL_ID"
[[kv_namespaces]]
binding = "RATE_LIMIT_KV"
id = "REPLACE_WITH_ACTUAL_ID"
preview_id = "REPLACE_WITH_ACTUAL_ID"
[[kv_namespaces]]
binding = "SESSION_KV"
id = "REPLACE_WITH_ACTUAL_ID"
preview_id = "REPLACE_WITH_ACTUAL_ID"
[[kv_namespaces]]
binding = "CACHE_KV"
id = "REPLACE_WITH_ACTUAL_ID"
preview_id = "REPLACE_WITH_ACTUAL_ID"
[[r2_buckets]]
binding = "R2_BUCKET"
bucket_name = "ai-support-assets"
# Service Binding
[[services]]
binding = "CLOUD_ORCHESTRATOR"
service = "cloud-orchestrator"
# Cron Triggers:
# - 매일 자정(KST): 만료 알림 + 데이터 아카이빙 + 정합성 검증
# - 매 5분: pending 상태 자동 정리
# - 매 시간: 장애 모니터링 체크
[triggers]
crons = ["0 15 * * *", "*/5 * * * *", "0 * * * *"]
# Secrets (wrangler secret put):
# - BOT_TOKEN: Telegram Bot Token
# - WEBHOOK_SECRET: Webhook 검증용 시크릿
# - OPENAI_API_KEY: OpenAI API 키
# - NAMECHEAP_API_KEY: Namecheap API 래퍼 인증 키
# - ADMIN_TELEGRAM_IDS: 관리자 Telegram ID (콤마 구분)
# - DEPOSIT_BANK_NAME: 입금 은행명
# - DEPOSIT_BANK_ACCOUNT: 입금 계좌번호
# - DEPOSIT_BANK_HOLDER: 예금주