This project is a fullstack chatbot that can impersonate Xavi Amatriain using Google's Gemini AI. It features a React frontend with a Node.js backend that supports both OpenAI and Google Gemini backends with automatic switching.
- Dual Backend Support: Switch between OpenAI GPT and Google Gemini
- Dynamic Backend Switching: Switch between backends during runtime via the chat interface
- Xavi Amatriain Impersonation: AI responds as if it were Xavi Amatriain
- Knowledge Base Integration: Uses PDF documents about Xavi's work and background
- File API Support: Uploads PDF files to Gemini File API for native document processing
- Conversation History: Maintains context across chat sessions
- Backend Switching: Easy configuration to switch between AI providers
- Built with React Chatbot Kit
- Modern UI with customizable styling
- Real-time chat interface
- Primary: Google Gemini with File API support
- Fallback: OpenAI GPT (optional)
- Backend Switcher: Automatic routing between AI providers
- File Upload: Native PDF processing with Gemini File API
- Node.js (v18 or higher)
- Google Gemini API key
- (Optional) OpenAI API key
- Clone the repository:
git clone https://github.com/xamat/Xavibot.git
cd Xavibot- Install dependencies:
npm install- Set up environment variables in
.env:
# API Configuration
REACT_APP_API_URL=http://localhost:8080
BACKEND_TYPE=gemini
# Gemini Configuration
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-2.5-flash
# Server Configuration
PORT=8080
CORS_ORIGIN=*
# Optional: OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here- Start the backend:
cd src/server && node index.js- Start the frontend (in a new terminal):
npm run start-frontend- Open http://localhost:8081/Xavibot in your browser
npm run start-frontend- Launches the React frontend on port 8081npm run dev-server- Launches the server using nodemon for developmentnpm run dev- Launches both frontend and backend concurrentlynpm run dev-gemini- Launches with Gemini backendnpm run dev-openai- Launches with OpenAI backend
npm run build- Builds the React frontend for productionnpm run deploy- Builds and deploys to GitHub Pages
npm run test-backends- Tests backend switching functionality
The system supports two types of backend switching:
The system automatically switches between backends based on the BACKEND_TYPE environment variable:
BACKEND_TYPE=gemini- Uses Google Gemini (default)BACKEND_TYPE=openai- Uses OpenAI GPT
You can switch between backends during a conversation by typing specific commands:
- Type
/useGeminior/useOpenAIto change backends - The system will automatically create a new thread for the new backend
- Your conversation history will be preserved within each backend
Note: When switching backends, you'll get a new conversation thread, so previous messages won't be available in the new backend. Gemini is used by default.
The chatbot uses PDF documents stored in src/server/:
xamatriain.pdf- Main knowledge base about Xavixamatriain_guide.pdf- Additional informationblog.pdf- Blog content
These files are automatically uploaded to Gemini File API on startup.
The system uses comprehensive instructions to make the AI impersonate Xavi Amatriain, including:
- Professional background and expertise
- Personal communication style
- Knowledge limitations and honesty
- Use of provided documents
- Set
REACT_APP_API_URL=http://localhost:8080in.env - Start backend:
cd src/server && node index.js - Start frontend:
npm run start-frontend
See:
GEMINI_API_KEY- Your Google Gemini API keyREACT_APP_API_URL- Backend server URL
- The browser initializes through
/session/initand receives a server-managed session id. - Do not expose
XAVIBOT_API_KEYor any equivalent secret in frontend build variables.
BACKEND_TYPE- Set to 'gemini' or 'openai' (default: 'gemini')GEMINI_MODEL- Gemini model to use (default: 'gemini-2.5-flash')OPENAI_API_KEY- OpenAI API key (if using OpenAI backend)PORT- Server port (default: 8080)CORS_ORIGIN- CORS origin (default: '*')
Xavibot/
├── src/
│ ├── server/
│ │ ├── gemini-backend.js # Gemini backend implementation
│ │ ├── openai-backend.js # OpenAI backend implementation
│ │ ├── backend-switcher.js # Backend switching logic
│ │ ├── config.js # Configuration and instructions
│ │ ├── app.js # Main Express server
│ │ └── index.js # Server entry point
│ ├── ActionProvider.js # Frontend action handling
│ ├── MessageParser.js # Message parsing logic
│ └── ChatbotContainer.js # Main chatbot component
├── public/ # Static assets
├── .env # Environment variables
└── package.json # Dependencies and scripts
- DEPLOYMENT.md - Backend/frontend deployment steps
- TESTING.md - Post-deploy smoke tests and regression checklist
- GEMINI_MIGRATION.md - Migration guide from OpenAI to Gemini
- BACKEND_SWITCHING.md - Backend switching implementation details
- KNOWLEDGE_BASE_STRATEGIES.md - Knowledge base strategies and approaches
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with React Chatbot Kit
- Powered by Google Gemini and OpenAI
- Knowledge base contains information about Xavi Amatriain's work and background