# Matrix GPT Bot A Matrix chat bot written in Go that leverages OpenAI to provide GPT-powered conversational responses. The bot listens for messages prefixed with `gpt:` or mentions (`@gpt:`) and maintains per-user conversation history. ## Features - **GPT Conversations**: Respond to `gpt: ` commands. - **Matrix Mentions**: Also triggers on full Matrix mention (`@gpt:domain`). - **Contextual History**: Keeps a conversation history per user. - **HTML Formatting**: Sends replies as plain text (no additional markup). - **Docker Support**: Easily containerize for deployment. ## Prerequisites - Go 1.20+ installed - Access to a Matrix homeserver (e.g., Synapse) - A bot user created on your Matrix server - An OpenAI API key ## Configuration Edit `config/config.go` to set your credentials: ```go func Load() *Config { return &Config{ Homeserver: "https://matrix.your-server.net", BotUserID: "@gpt:your-server.net", // Your bot's user ID AccessToken: "YOUR_MATRIX_ACCESS_TOKEN", // Your Matrix access token OpenAIKey: "YOUR_OPENAI_API_KEY", // Your OpenAI API key } } ``` ## Local Development ```bash # Clone the repository git clone https://git.ewnix.net/phlux/matrix-gpt-bot.git cd matrix-gpt-bot # Initialize modules and download dependencies go mod init matrix-gpt-bot go mod tidy # Run the bot go run . ``` Invite your bot into a Matrix room and test: ``` gpt: Hello, bot! ``` ## Docker Deployment To build a Docker image: ```bash docker build -t matrix-gpt-bot:latest . ``` Run the container: ```bash docker run -d --name matrix-gpt-bot matrix-gpt-bot:latest ``` ## Kubernetes (K3s) 1. Create a namespace and pull-secret for private registries if needed. 2. Deploy with a standard Deployment manifest, mounting environment variables for credentials. ## Command Reference - `gpt: ` – Sends `` to OpenAI and returns the response. - `@gpt:domain ` – Alternate trigger via mention. ## License MIT © Your Name