A conversational AI-powered data analyst chatbot that seamlessly integrates with Looker Business Intelligence platforms. Get instant insights from your data through natural language conversations that can be embedded on any website.
Ask questions about your data in plain English without needing SQL knowledge. The AI understands context and provides meaningful insights.
Example queries:
- "What are our top 10 page titles on our website over the last 30 days?"
- "Show me sales trends by region"
- "What's our customer acquisition cost this quarter?"
- Real-time connection to your Looker platform
- Automatic schema discovery and query generation
- Secure authentication with your Looker credentials
- Support for complex analytical queries
- Simple JavaScript widget that works on any website
- Floating chat button with customizable positioning
- Responsive design that works on desktop and mobile
- Clean, modern interface with light/dark theme support
- Secure user registration and login system
- Per-user Looker configuration storage
- Settings panel for API key management
- Session-based chat history
- Backend: Flask (Python)
- Database: PostgreSQL
- AI/ML: OpenAI GPT-4o, LangChain Looker Agent
- Frontend: Vanilla JavaScript, Bootstrap CSS
- Authentication: Flask-Login with secure password hashing
- BI Integration: Looker API with JDBC driver support
Before you begin, ensure you have:
- Looker BI Instance: Access to a Looker platform with API credentials
- OpenAI API Key: For natural language processing capabilities
- Python 3.8+: For running the Flask backend
- PostgreSQL Database: For storing user data and configurations
git clone https://github.com/your-username/looker-data-analyst-chatbot.git
cd looker-data-analyst-chatbot
pip install -r requirements.txt
Create a .env
file in the project root:
# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/looker_chatbot
# Session Security
SESSION_SECRET=your-secure-session-secret
# Optional: Default Looker Configuration (users can override in settings)
LOOKER_BASE_URL=https://your-looker-instance.looker.com
LOOKER_CLIENT_ID=your_looker_client_id
LOOKER_CLIENT_SECRET=your_looker_client_secret
OPENAI_API_KEY=your_openai_api_key
LOOKML_MODEL_NAME=your_model_name
# JDBC Driver Path
JDBC_DRIVER_PATH=./drivers/looker-jdbc.jar
python -c "from app import db; db.create_all()"
python main.py
The application will be available at http://localhost:5000
-
Create API Credentials in your Looker Admin panel:
- Go to Admin β Users β API Keys
- Generate a new API3 key pair
- Note the Client ID and Client Secret
-
Configure Permissions:
- Ensure your API user has access to the models you want to query
- Grant necessary permissions for data exploration
Users can configure their own Looker credentials through the settings panel:
- Click the settings icon in the chat widget
- Enter your Looker instance details:
- Base URL (e.g.,
https://company.looker.com
) - Client ID and Client Secret
- OpenAI API Key
- LookML Model Name
- Base URL (e.g.,
- Test the connection to verify credentials
Add this code snippet to any webpage to embed the chatbot:
<!-- CSS -->
<link rel="stylesheet" href="https://your-domain.com/static/widget.css">
<!-- JavaScript -->
<script src="https://your-domain.com/static/widget.js"></script>
<script>
const chatWidget = new LookerChatWidget({
apiBaseUrl: 'https://your-domain.com'
});
</script>
Important: Replace your-chatbot-server.replit.app
with the actual URL where your chatbot server is hosted. This should NOT be your website's domain unless you're hosting the chatbot there.
const chatWidget = new LookerChatWidget({
apiBaseUrl: 'https://your-domain.com',
position: 'bottom-right', // bottom-left, top-right, top-left
theme: 'light', // light, dark
primaryColor: '#6366F1',
autoOpen: false
});
POST /api/chat
- Send message to chatbotPOST /api/chat/clear
- Clear chat history
POST /api/auth/login
- User loginPOST /api/auth/register
- User registrationPOST /api/auth/logout
- User logoutGET /api/auth/status
- Check authentication status
POST /api/settings
- Save user settingsGET /api/settings
- Get user settingsPOST /api/test-connection
- Test Looker connection
- Secure Password Storage: Passwords are hashed using Werkzeug's secure methods
- Session Management: Flask-Login handles user sessions securely
- API Key Encryption: User API keys are stored securely in the database
- CORS Configuration: Proper CORS setup for cross-domain embedding
- Input Validation: All user inputs are validated and sanitized
404 Errors When Using Widget on External Website
- The most common issue: Make sure the
apiBaseUrl
in your widget initialization points to your chatbot server, not your website - Correct example:
apiBaseUrl: 'https://your-chatbot-server.replit.app'
- Incorrect:
apiBaseUrl: 'https://your-website.com'
(unless the chatbot is hosted there) - Check browser console for "404 Not Found" errors on
/api/chat
endpoint
Connection Failed to Looker
- Verify your Looker credentials in the settings panel
- Check that your Looker instance URL is correct
- Ensure your API user has proper permissions
Chat Not Responding
- Verify your OpenAI API key is valid and has sufficient credits
- Check the browser console for any JavaScript errors
- Ensure the backend server is running
Widget Not Loading
- Check that the CSS and JS files are accessible from your domain
- Verify CORS configuration allows your domain
- Check browser console for loading errors
Enable debug logging by setting:
import logging
logging.basicConfig(level=logging.DEBUG)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- Open an issue on GitHub
- Check the Documentation
- Review the troubleshooting section above
This project is optimized for Replit deployment:
- Import the repository to Replit
- Configure environment variables in the Secrets tab
- Run the project - it will automatically start on port 5000
- Use the generated Replit URL for widget integration
For production environments:
- Use a production WSGI server (Gunicorn, uWSGI)
- Set up proper SSL/TLS certificates
- Configure a reverse proxy (Nginx, Apache)
- Use environment-specific configuration files
- Set up monitoring and logging
Built with β€οΈ using Looker BI, LangChain, and Flask