Skip to content

CodeSenior/support-bot-rag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Support Bot with RAG

An intelligent customer support chatbot using RAG (Retrieval-Augmented Generation) with OrkaJS, Next.js and NestJS.

πŸ“‹ Table of contents

🎯 Overview

This project is a complete example of a Support Bot application using RAG technology to provide accurate, knowledge-based answers. It demonstrates the integration of Orka AI into a modern, full-stack architecture.

Technologies used

Frontend:

  • Next.js 14 (App Router)
  • React 18
  • TypeScript
  • TailwindCSS
  • Lucide Icons

Backend:

  • NestJS
  • OrkaJS (RAG & LLM)
  • OpenAI GPT-4
  • TypeScript

Infrastructure:

  • Docker & Docker Compose
  • NPM Workspaces (Mono-repo)

✨ Features

  • πŸ’¬ Real-time chat - Intuitive conversation interface
  • 🧠 Intelligent RAG - Answers based on a knowledge base
  • 🎨 Modern UI - Responsive design with smooth animations
  • πŸ”’ Type-safe - TypeScript end-to-end
  • 🐳 Dockerized - Easy deployment with Docker
  • πŸ“¦ Mono-repo - Simplified management with NPM Workspaces

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚
β”‚   (Next.js 14)  β”‚
β”‚   Port: 3000    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚ HTTP/REST
         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Backend       β”‚
β”‚   (NestJS)      β”‚
β”‚   Port: 3001    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
    β”‚ Orka AI  β”‚
    β”‚   RAG    β”‚
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
    β”‚ OpenAI   β”‚
    β”‚ GPT-4    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Prerequisites

  • Node.js >= 18.0.0
  • npm >= 9.0.0
  • Docker & Docker Compose (optional)
  • OpenAI API key

πŸš€ Installation

πŸ“– For a detailed installation guide, see INSTALLATION.md

Quick installation

# 1. Install dependencies
npm install

# 2. Configure the backend
cp apps/backend/.env.example apps/backend/.env
# Edit apps/backend/.env and add your OPENAI_API_KEY

# 3. Start the application
npm run dev

# 4. Access http://localhost:3000

βš™οΈ Configuration

Backend (.env)

NODE_ENV=development
PORT=3001
OPENAI_API_KEY=your_openai_api_key_here

Frontend (.env)

NEXT_PUBLIC_API_URL=http://localhost:3001

πŸ’» Usage

Development mode

# Start backend and frontend simultaneously
npm run dev

# Or separately:
npm run dev:backend   # Backend on http://localhost:3001
npm run dev:frontend  # Frontend on http://localhost:3000

Production mode

# Build
npm run build

# Start
npm start

Access the application

🐳 Docker

Development with Docker

# Start in development mode
docker-compose -f docker-compose.dev.yml up

# With rebuild
docker-compose -f docker-compose.dev.yml up --build

Production with Docker

# Build and start
npm run docker:build
npm run docker:up

# Or directly
docker-compose up --build

# Stop
npm run docker:down

Docker environment variables

Create a .env file at the root:

OPENAI_API_KEY=your_openai_api_key_here

πŸ”Œ API Endpoints

POST /api/support/ask

Ask a question to the support bot.

Request:

{
  "question": "How do I reset my password?",
  "conversationId": "optional-conversation-id"
}

Response:

{
  "answer": "To reset your password, follow these steps...",
  "conversationId": "conv_1234567890_abc123"
}

GET /api/support/health

Check the service status.

Response:

{
  "status": "healthy",
  "timestamp": "2024-03-06T15:30:00.000Z"
}

🎨 Customization

Modify the knowledge base

Edit apps/backend/src/support-bot/orka.service.ts in the initializeKnowledgeBase() method:

const supportDocuments = [
  {
    content: `# Your content here`,
    metadata: { category: 'category-name', topic: 'topic-name' },
  },
  // Add more documents...
];

Customize the system prompt

Modify the systemPrompt in apps/backend/src/support-bot/orka.service.ts:

systemPrompt: `You are a personalized support assistant...`

Change the LLM model

In apps/backend/src/support-bot/orka.service.ts:

const llmAdapter = new OpenAIAdapter({
  apiKey,
  model: 'gpt-4-turbo-preview', // Change here
  temperature: 0.7,
});

πŸ§ͺ Tests

# Backend
cd apps/backend
npm run test

# Frontend
cd apps/frontend
npm run test

Checklist before sharing

  • Remove node_modules and build files
  • Remove all .env.local files (contain API keys)
  • Verify that .gitignore is correct
  • Test installation from scratch

οΏ½ Licence

MIT

🀝 Contribution

Contributions are welcome! Consult CONTRIBUTING.md for more details.

πŸ“§ Support

For any questions, consult:


Developed with ❀️ using OrkaJS

About

Support Bot with RAG - Mono-repo OrkaJS project test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors