A Matrix bot that searches Wikipedia for articles based on user commands, summarises them using OpenAI's GPT model, caches the summaries, and replies in Matrix rooms.
- Wikipedia Search: Searches for articles on Wikipedia based on user input.
- Article Summarisation: Uses OpenAI's GPT model to summarise articles.
- Caching Mechanism: Caches summaries to avoid redundant API calls.
- Configurable: All settings are configurable via a YAML file.
- Concurrent Requests: Handles multiple requests concurrently using Goroutines.
- Go (version 1.22 or higher)
- Docker (if you prefer running the bot in a container)
- Git (for cloning the repository)
- An OpenAI API key
- A Matrix account and access token
git clone https://github.com/tcpipuk/go-matrix-openai-wiki-bot.git
cd go-matrix-openai-wiki-bot
-
Copy the sample configuration file:
cp config.example.yaml config.yaml
-
Edit
config.yaml
and update the following fields:-
Matrix Configuration:
homeserver
: Your Matrix homeserver URL.user_id
: The Matrix user ID of your bot.access_token
: The access token for your bot.
-
OpenAI Configuration:
api_key
: Your OpenAI API key.model
: The OpenAI model you wish to use (e.g.,gpt-4o-mini
).system_prompt
: The prompt provided to the model.
-
Bot Configuration:
output_dir
: Directory where summaries will be cached.command
: The command prefix to trigger the bot (e.g.,!wiki
).
-
Ensure you have Go installed.
-
Install dependencies:
go mod download
-
Build the application:
go build -o go-matrix-openai-wiki-bot .
-
Run the application:
./go-matrix-openai-wiki-bot
-
Build the Docker image:
docker build -t go-matrix-openai-wiki-bot .
-
Run the Docker container:
docker run -d \ -v $(pwd)/config.yaml:/app/config.yaml \ -v $(pwd)/output:/app/output \ --name go-matrix-openai-wiki-bot \ go-matrix-openai-wiki-bot
Note: The -v
flags mount your local config.yaml
and output
directory into the container.
-
Invite your bot to a Matrix room.
-
Send a message using the configured command, e.g.:
!wiki Computer
-
The bot should reply with a summarised version of the Wikipedia article.
Alternatively, you can pull the pre-built Docker image from GHCR:
docker pull ghcr.io/tcpipuk/go-matrix-openai-wiki-bot:latest
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT Licence. See the LICENSE file for details.