How gouravdev246/reactivechatbot works
ReactiveChatBot is a Telegram companion with an Express API. A user message arrives through the webhook, is handled by the Telegram service, receives a memory-aware AI response, and can reset a delayed proactive follow-up. The scheduler persists scheduled-message state, queues work, and a worker checks inactivity, asks an AI decision service whether to send, then dispatches through Telegram. The graph also includes monitoring/simulation endpoints and the short-history, prompt, persistence, and queue layers. The README is empty; some worker and AI internals were only partially excerpted, so uncertain links are omitted or marked dashed.
Main entry points: proactiveMessage.worker.ts Proactive worker · chat.telegram.ts Telegram handler · chat.longmemory.ts Memory-aware chat · queue.ts Job queue
Components 23
API and Telegram
- Server entry
server.ts - Express API
src/app.ts - Telegram routes
src/routes/telegram.routes.ts - Telegram handler
src/services/telegram/chat.telegram.ts - Scheduler routes
src/routes/scheduler.routes.ts
Conversation AI
- Memory-aware chat
src/services/ai/chat.longmemory.ts - Direct chat
src/services/ai/chat.sendmessage.ai.ts - Short-history chat
src/services/ai/chat.shorthistory.ts - Direct prompt
src/Prompt/direct.chat.ts - Short prompt
src/Prompt/short.chat.ts - Proactive decision
src/services/ai/proactive.decision.ai.ts
Proactive Scheduler
- Job queue
src/services/scheduler/queue.ts - Proactive worker
src/jobs/proactiveMessage.worker.ts - Worker wrapper
src/services/scheduler/worker.ts - Scheduler schemas
src/schemas/scheduler.schema.ts
State and Integrations
- Prisma client
src/config/prisma.ts - Redis connection
src/config/redis.ts - Application database
prisma/schema.prisma - Redis history and jobs
- Vector memory index
Other components
- Telegram user
- Telegram
- Language models
Connections 37
- Server entry → Express API: starts
server.ts - Server entry → Worker wrapper: starts
server.ts - Telegram user → Telegram: sends message
- Telegram → Telegram routes: posts webhook
- Express API → Telegram routes: mounts routes
src/app.ts - Express API → Scheduler routes: mounts routes
src/app.ts - Express API → Telegram handler: routes webhook
src/app.ts - Telegram routes → Telegram handler: dispatches
src/routes/telegram.routes.ts - Telegram handler → Memory-aware chat: requests reply
src/services/telegram/chat.telegram.ts - Telegram handler → Job queue: schedules check
src/services/telegram/chat.telegram.ts - Telegram handler → Telegram: sends reply
src/services/telegram/chat.telegram.ts - Telegram handler → Prisma client: reads user
src/services/telegram/chat.telegram.ts - Memory-aware chat → Direct prompt: uses prompt
src/services/ai/chat.longmemory.ts - Memory-aware chat → Redis history and jobs: loads history
src/services/ai/chat.longmemory.ts - Memory-aware chat → Vector memory index: queries memories
src/services/ai/chat.longmemory.ts - Memory-aware chat → Language models: generates response
src/services/ai/chat.longmemory.ts - Memory-aware chat → Direct chat: may delegate
- Short-history chat → Short prompt: uses prompt
src/services/ai/chat.shorthistory.ts - Direct chat → Direct prompt: uses prompt
src/services/ai/chat.sendmessage.ai.ts - Scheduler routes → Job queue: reads stats
src/routes/scheduler.routes.ts - Scheduler routes → Proactive worker: checks worker
src/routes/scheduler.routes.ts - Scheduler routes → Prisma client: reads records
src/routes/scheduler.routes.ts - Job queue → Prisma client: stores schedules
src/services/scheduler/queue.ts - Job queue → Redis connection: opens connection
src/services/scheduler/queue.ts - Job queue → Scheduler schemas: validates payload
src/services/scheduler/queue.ts - Redis connection → Redis history and jobs: connects
src/config/redis.ts - Prisma client → Application database: accesses
- Proactive worker → Prisma client: loads user and logs
src/jobs/proactiveMessage.worker.ts - Proactive worker → Memory-aware chat: retrieves memories
src/jobs/proactiveMessage.worker.ts - Proactive worker → Proactive decision: requests decision
src/jobs/proactiveMessage.worker.ts - Proactive worker → Telegram handler: dispatches message
src/jobs/proactiveMessage.worker.ts - Proactive worker → Redis history and jobs: writes history
src/jobs/proactiveMessage.worker.ts - Proactive worker → Scheduler schemas: uses job payload
src/jobs/proactiveMessage.worker.ts - Proactive worker → Job queue: consumes jobs
src/jobs/proactiveMessage.worker.ts - Proactive decision → Scheduler schemas: validates decision
src/services/ai/proactive.decision.ai.ts - Proactive decision → Language models: evaluates follow-up
- Telegram handler → Telegram: sends outbound
src/services/telegram/chat.telegram.ts