Completed

Support AI — RAG Telegram Chatbot

RAG-powered Telegram support chatbot with an admin dashboard, combining keyword and vector search over a knowledge base to answer trading/TradingView indicator support questions.

Node.jsExpress.jsTelegrafOpenAI GPT-4o-miniMongoDBMongoose+8 more

Project Showcase

Admin panel — conversation review with Correct / Needs Improvement feedback

Overview

A two-service system built for trading/TradingView indicator support: a Node.js/Express backend running a Telegraf-based Telegram bot with a retrieval-augmented generation (RAG) pipeline, and a Next.js admin dashboard for managing the knowledge base, conversations, users, and announcements. User messages are answered by GPT-4o-mini, grounded in context pulled from a hybrid retrieval layer — MongoDB text search over a curated knowledge base plus Atlas vector search over embedded Telegram channel messages. An admin feedback loop lets moderators correct bot answers, with approved corrections injected as highest-priority context in future responses, acting as a lightweight learning loop without model fine-tuning.

Architecture

Telegram (webhook)
Bot Server (Express + Telegraf)

Hybrid Retrieval

MongoDB Text Search (Knowledge Base)
Atlas Vector Search (Channel Chat)
Admin Feedback Context (priority)
OpenAI GPT-4o-mini
Reply to User + MongoDB Persistence

Tech Stack

Node.jsExpress.jsTelegraf (webhook-based)
OpenAI GPT-4o-mini (chat)text-embedding-ada-002 (embeddings)
MongoDBMongooseAtlas Vector SearchMongoDB Text Index
Next.js (App Router)ReactTypeScriptTailwind CSS
JWT (access + refresh)bcryptjsMulterpdf-parsemammoth

Features

Bot & Retrieval

  • RAG-based Q&A grounded in a knowledge base, answered by GPT-4o-mini
  • Hybrid retrieval — MongoDB text search over curated docs + Atlas vector search over embedded channel messages
  • Custom weighted relevance scoring for matching video-reference documents
  • Short-term conversation memory (last 5 turns) per user
  • Keyword and command-based human escalation with admin DM notification

Admin Dashboard

  • Knowledge base ingestion — PDF/TXT/MD/JSON upload, chunked and embedded
  • Admin feedback learning loop — corrections stored and injected as highest-priority context
  • Telegram channel ingestion — posts embedded and indexed for retrieval
  • User moderation — block/unblock Telegram users
  • Broadcast announcements with delivery/failure tracking
  • JWT auth with refresh-token rotation and bcrypt-hashed admin passwords

Engineering Challenges

Challenge 1: Balancing Precision and Recall Across Two Content Types

Challenge

Curated knowledge-base documents needed exact/keyword-level precision, while noisy, high-volume Telegram channel chat needed semantic matching — a single retrieval strategy couldn't serve both well.

Solution

Built a two-tier retrieval layer: MongoDB text search for curated knowledge-base docs and Atlas vector search (text-embedding-ada-002) for embedded channel messages, querying both in parallel and merging the results into the response context.

Challenge 2: Improving Answer Quality Without Retraining the Model

Challenge

Bot answers needed to keep improving based on admin review, but retraining or fine-tuning a model for every correction wasn't practical.

Solution

Built an admin feedback loop where moderators mark answers correct or needs-improvement and submit corrections; approved corrections are stored and re-injected as highest-priority, in-context guidance ahead of the general knowledge base — a lightweight RLHF-style loop with no fine-tuning required.

Project Details

Status

Completed

Interested in working together?

Let's talk about how I can help build and ship your next production application.