This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Install dependencies:
bun install - Start production:
bun run start(runssrc/index.ts) - Start development:
bun run dev(runs with file watching) - Database migrations:
drizzle-kitcommands (checkdrizzle.config.ts)
This is a Telegram bot for "Takin AI" - a conversational AI system for Bhutan's digital governance initiative that integrates with:
-
Telegram Bot (
src/index.ts): Main bot logic using Telegraf framework- Handles text and voice messages
- Built-in rate limiting (100 requests/hour per user)
- Session management for user state
- Commands:
/auth,/profile,/claim
-
AI Processing (
src/openai.ts): Message processing through OpenAI- Text message handling
- Voice transcription integration
-
Database Layer (
src/db/):- Schema (
schema.ts): Drizzle ORM schemas forproofsandresponsestables - Client (
client.ts): Neon PostgreSQL connection - API (
api.ts): Database operations for profiles and responses
- Schema (
-
Audio Processing (
src/transcription.ts): Voice message transcription via Whisper API (RunPod) -
Webhook Server (
src/webhook.ts): Express server for NDI webhook callbacks
- PostgreSQL: Using Neon serverless with Drizzle ORM
- OpenAI: For message processing and AI responses
- Whisper API: For voice message transcription (RunPod hosted)
- NDI Wallet: Bhutan's digital identity system for authentication and credentials
- Telegram: Bot API for messaging interface
Required environment variables (see .env.example):
BOT_TOKEN: Telegram bot tokenDATABASE_URL: PostgreSQL connection stringNDI_CLIENT_ID,NDI_CLIENT_SECRET: NDI integration credentialsOPENAI_API_KEY: OpenAI API accessWHISPER_API_KEY: RunPod Whisper API keyDEPLOYMENT_URL,LINK_URL: Webhook and frontend URLsHMAC_SECRET_KEY,HASH_SALT: Security keys for data integrity
- User interacts via Telegram (text/voice)
- Rate limiting and session management applied
- Voice messages transcribed via Whisper API
- Messages processed through OpenAI for AI responses
- User interactions logged to database
- NDI authentication enables profile access
- After 15+ interactions, users can claim credentials via NDI wallet
- Rate limiting (100 requests/hour per user)
- HMAC verification for webhooks
- Environment-based configuration
- Session-based user state management