A Next.js-based AI chatbot application featuring intelligent responses, knowledge management, and advanced training capabilities.
- AI-Powered Chat: GPT-4o mini integration with contextual responses
- Knowledge Management: GitBook documentation integration with MongoDB storage
- Training System: Secret training mode for custom knowledge enhancement
- Client Management: Message limits and usage tracking
- Modern Interface: Responsive design with smooth animations
-
Install dependencies
npm install
-
Configure environment
Create
.env.local:NEXT_PUBLIC_OPENAI_API_KEY=your_openai_api_key_here MONGODB_URI=your_mongodb_connection_string_here
-
Start development server
npm run dev
-
Initialize knowledge base (optional)
curl -X POST http://localhost:3000/api/training/gitbook-init
Visit http://localhost:3000 to access the application.
| Variable | Description |
|---|---|
NEXT_PUBLIC_OPENAI_API_KEY |
OpenAI API key for GPT-4o mini |
MONGODB_URI |
MongoDB connection string |
MongoDB Atlas (Recommended)
- Create account at MongoDB Atlas
- Create a free cluster
- Get connection string and add to
.env.local
Local MongoDB
mongodb://localhost:27017/koa-ai-chatThe application includes a secret training mode that allows users to enhance the bot's knowledge base.
- Activate: Send a secret code as the first line of your message
- Train: All subsequent messages are analyzed and stored
- Exit: Send
exit training modeto stop the session
- AI Analysis: Automatic content analysis for intent, sentiment, and topics
- Knowledge Integration: Training data becomes part of the searchable knowledge base
- Natural Responses: Bot responds conversationally during training sessions
src/
βββ app/
β βββ page.tsx # Main landing page
β βββ layout.tsx # Root layout
β βββ api/ # API routes
βββ components/
β βββ ChatModal.tsx # Main chat interface
βββ lib/
β βββ mongodb.ts # MongoDB connection utilities
βββ models/ # Database models
βββ types/ # TypeScript definitions
POST /api/client/status- Get client status and message countPOST /api/client/increment- Increment message countPOST /api/training/secret-training- Handle training sessionsPOST /api/training/gitbook-init- Initialize knowledge basePOST /api/training/gitbook-search- Search content
GET /api/admin/training-data- View training sessionsGET /api/admin/training-gitbook- View GitBook content
API Key Problems
- Verify
.env.localexists with correct variable names - Restart development server after environment changes
MongoDB Connection
- Check
MONGODB_URIformat and credentials - Ensure database is accessible
Training Mode
- Verify secret codes in
.env.local - Check MongoDB connectivity
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
| Platform | Link | Purpose |
|---|---|---|
| Telegram | t.me/FroganBee.sol | Announcements & Support |
| X | x.com/FroganBee.sol | News & Updates |
MIT License