A Python chatbot using OpenAI GPT-4o-mini with Saleor GraphQL and MongoDB integration.
- Install dependencies:
pip install -r requirements.txt- Configure environment variables in
.env:
- Add your OpenAI API key
- Configure Saleor GraphQL endpoint and API token
- Add MongoDB connection string (for chat storage)
- Add Langfuse keys for monitoring
- Ensure your Saleor instance has proper API access configured
python main.pypython app.pymain.py- Command-line interface for the chatbotapp.py- Flask web API server with CORS support and input sanitizationchatbot.py- Main chatbot logic with OpenAI GPT-4o-mini integration and Langfuse monitoringdatabase.py- Database abstraction layer handling Saleor GraphQL and MongoDB connections
.env- Environment variables (API keys, database credentials).env.example- Template for environment configurationrequirements.txt- Python dependencies (OpenAI, Flask, PostgreSQL, MongoDB, etc.)gunicorn.conf.py- Gunicorn WSGI server configurationecosystem.config.js- PM2 process manager configuration
app/- Next.js 16 app directory structurecomponents/- React components including main chatbot interfacehooks/- Custom React hooks for mobile detection and toast notificationslib/- Utility functionspublic/- Static assets
- Next.js 16 with React 19
- TypeScript for type safety
- Tailwind CSS for styling
- Radix UI components
- Integrates with Saleor e-commerce platform via GraphQL API
- Fetches order information and product categories
- Uses API tokens for authentication
- Stores chat conversation history
- Uses unique UUIDs for session management
- Anonymous Chat Sessions - No authentication required
- Persistent Chat History - MongoDB with UUID sessions
- AI Integration - OpenAI GPT-4o-mini with custom prompts
- Order Lookup - Function calling to retrieve order information
- Product Categories - AI can fetch available product categories
- Observability - Langfuse monitoring and analytics
- Security - Input sanitization and request size limits
- Modern Frontend - React 19 with TypeScript and Tailwind
- Production Ready - Gunicorn + PM2 deployment setup
- POST
/chat/init- Initialize chat session - POST
/chat- Main chat endpoint - GET
/health- Health check endpoint