A Discord bot with a web dashboard for managing RAG (Retrieval-Augmented Generation) entries and auto-responses. The dashboard syncs with the bot in real-time, allowing you to continuously improve the bot's knowledge base.
- 🤖 Discord Bot: Automatically responds to forum posts using RAG and AI
- 📊 Web Dashboard: Manage RAG entries and auto-responses through a beautiful UI
- 🔄 Real-time Sync: Dashboard changes automatically sync to the bot
- 🎯 Smart Matching: Keyword-based matching with relevance scoring
- 🧠 AI-Powered: Uses Google Gemini AI for intelligent responses
- Frontend: React + TypeScript + Vite (deployed on Vercel)
- Backend API: Vercel Serverless Functions
- Discord Bot: Python with discord.py
- AI: Google Gemini API
git clone <your-repo-url>
cd RAG-Bot-v2
npm install
pip install -r requirements.txtCreate a .env file or set in Vercel dashboard:
VITE_API_URL=https://your-app.vercel.app/apiCreate a .env file in the root:
DISCORD_BOT_TOKEN=your_discord_bot_token
GEMINI_API_KEY=your_gemini_api_key
SUPPORT_FORUM_CHANNEL_ID=your_channel_id
DATA_API_URL=https://your-app.vercel.app/api/data- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" section and create a bot
- Copy the bot token
- Enable these intents:
- Message Content Intent
- Server Members Intent
- Invite bot to your server with appropriate permissions
- Push code to GitHub
- Import project in Vercel
- Set build command:
npm run build - Set output directory:
dist - Add environment variables in Vercel dashboard
- Deploy!
After deploying to Vercel, update your bot's .env file:
DATA_API_URL=https://your-actual-vercel-url.vercel.app/api/datapython bot.pyThe bot will:
- Fetch initial data from the dashboard API
- Sync data every 5 minutes automatically
- Respond to new forum posts in your configured channel
- Access your dashboard at
https://your-app.vercel.app - Navigate to "RAG Management"
- Add/Edit/Delete RAG entries and auto-responses
- Changes automatically sync to the bot within 5 minutes
- Use
/reloadcommand in Discord to force immediate sync
/reload- Manually reload data from dashboard (Admin only)/stop- Stop the bot gracefully (Admin only)
├── api/
│ └── data.ts # Vercel API route for data sync
├── components/ # React components
├── services/
│ ├── dataService.ts # API service for dashboard
│ └── geminiService.ts # Gemini AI service
├── hooks/
│ └── useMockData.ts # Data management hook
├── bot.py # Discord bot
├── requirements.txt # Python dependencies
└── package.json # Node dependencies
-
Dashboard → Bot:
- Dashboard saves changes to Vercel API
- Bot polls API every 5 minutes
- Bot updates its internal database
-
Bot → Dashboard:
- Bot uses current data for responses
- Dashboard fetches data on load
- Both stay in sync automatically
- Use a database (Supabase, MongoDB Atlas, or Vercel Postgres)
- Implement proper authentication
- Add rate limiting
- Use environment variables for sensitive data
- Check bot is online in Discord
- Verify channel ID is correct
- Check bot has permissions in the channel
- Verify
DATA_API_URLin bot's.envmatches your Vercel URL - Check API is accessible:
curl https://your-app.vercel.app/api/data - Check bot logs for error messages
- Verify build completed successfully
- Check Vercel deployment logs
- Ensure environment variables are set
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT