This bot allows users to query lecture notes using a RAG (Retrieval-Augmented Generation) pipeline through Mattermost.
.
├── src/ # Source code directory
│ ├── mattermost_bot.py # Mattermost bot implementation
│ ├── app.py # RAG pipeline server
│ └── ... # Other source files
├── data/ # Data directory for lecture notes
├── chroma_db/ # Vector database storage
├── requirements.txt # Python dependencies
├── start_servers.sh # Script to start all services
└── manage_ngrok_service.sh # Script to manage ngrok service
- Python 3.8 or higher
- Mattermost server with admin access
- Google API key for the RAG pipeline
- OpenAI API key for web search functionality
- Clone the repository
- Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Unix/macOS # or .\venv\Scripts\activate # On Windows
- Install dependencies:
pip install -r requirements.txt
- Copy
.env.example
to.env
and fill in the required values:MATTERMOST_URL
: Your Mattermost server URLBOT_TOKEN
: Your Mattermost bot tokenGOOGLE_API_KEY
: Your Google API keyOPENAI_API_KEY
: Your OpenAI API key
- Log in to your Mattermost server as an administrator
- Go to System Console > Integrations > Bot Accounts
- Create a new bot account:
- Username: lecture-bot
- Display Name: Lecture Notes Bot
- Description: Bot for querying lecture notes
- Copy the generated bot token and add it to your
.env
file
-
Start the RAG pipeline server:
python src/app.py
-
Start the Mattermost bot server:
python src/mattermost_bot.py
Alternatively, you can use the provided script to start both services:
./start_servers.sh
-
The bot will be available in Mattermost using the
/lecture
command
In any Mattermost channel, users can interact with the bot using:
@knowledge-agent <your question>
For example:
@knowledge-agent What is the definition of a vector norm?
The bot will respond with:
- The answer to your question
- Sources used to generate the answer
- Any relevant context from the lecture notes
- Natural language querying of lecture notes
- Source attribution for answers
- Web search fallback when local context is insufficient
- Markdown formatting for better readability
- Error handling and user feedback
If you encounter issues:
- Check the logs in the
logs/
directory for error messages - Verify your API keys are correct in the
.env
file - Ensure the Mattermost bot has proper permissions
- Check that the lecture notes are properly indexed in the RAG pipeline
- Keep your API keys and bot tokens secure
- Do not commit the
.env
file to version control - Regularly rotate your bot tokens
- Monitor bot usage and implement rate limiting if necessary