Built an AI chatbot that actually understands your business documents - Here’s my tech stack and lessons learned
After 2 days of development, I just shipped an intelligent chatbot system for the hospitality industry. Unlike generic chatbots, this one reads uploaded business documents and provides contextual responses.
The Problem: Most chatbots are either rule-based (limited) or use generic AI (unhelpful). Customers ask “What are your check-in hours?” and get “I’m sorry, I don’t have that information.”
My Solution - Intelligent Knowledge Retrieval:
Tech Stack:
- Backend: NestJS + TypeScript
- Database: MongoDB (conversations) + Supabase (file storage)
- AI: OpenAI GPT-4 + Embeddings API
- Processing: Background jobs with cron scheduling
- File Parsing: pdf-parse + mammoth for document extraction
Architecture Overview:
- Upload Pipeline: PDF/DOC files → Text extraction → Chunking → Vector embeddings
- Smart Retrieval: User question → Vector similarity search → Relevant context
- AI Generation: Context + conversation history → GPT-4 → Intelligent response
Key Technical Challenges Solved:
1. Background Processing
- Cron jobs process uploaded files every 5 minutes
- Queue management prevents duplicate processing
- Status tracking: pending → processing → completed/failed
2. Vector Search Implementation
- 1000-character chunks with 100-character overlap
- OpenAI text-embedding-ada-002 for embeddings
- Cosine similarity with 0.7 threshold
- Fallback to text search if vector search fails
3. Context Management
- Maintain conversation history (last 10 messages)
- Combine relevant chunks into coherent context
- Source attribution for transparency
Performance:
- Response time: 2-6 seconds (including AI generation)
- Concurrent processing: 5 files simultaneously
- Search accuracy: 85%+ relevance with proper knowledge base
Lessons Learned:
- Chunking strategy matters - Sentence boundary detection prevents cut-off context
- Fallback mechanisms are crucial - Vector search can fail, always have text search backup
- Rate limiting is essential - Both for AI APIs and user experience
- Background processing scales better - Don’t process files synchronously
Results:
- 90% reduction in “I don’t know” responses
- Contextual answers about business hours, amenities, policies
- Source tracking shows which documents contributed to responses
The system now powers customer support for hospitality businesses, automatically learning from their uploaded manuals and FAQs.
Happy to answer technical questions about implementation!
GitHub: (keeping private for now) Demo: Available on request
Posted Jul 6, 2025, 4:59 PM UTC