This is a small bot for matrix which brings chatgpt functionality into any matrix room so that it can be collaboratively used.
Once the bot is invited to a room, it will join and wait until it is mentioned in a message. The bot supports multiple sessions just like the chatgpt webinterface and saves session history in a SQLite database. Sessions can be managed with different commands (see examples).
Please note:
Here are some example screenshots. The help command is used to get a list of available commands.

With no commands, the bot will respond with an answer generated by the openai API.

The new command starts a session.

There are multiple commands to manage the sessions.



Poetry is used for dependency management.
Install dependencies:
poetry installProvide environment variables or a .env file with these variables:
# Set to true to run productively.
PRODUCTION=false
# Path to an sqlite db. If it doesn't exist, it will be automatically created!
DB_PATH="./mydb.db"
# Matrix homeserver url.
MATRIX_HOMESERVER="https://my.matrix.home.server"
# User name of the user used as the bot.
MATRIX_BOT_USERNAME="ai-assistant"
# An access token fot the user.
MATRIX_ACCESS_TOKEN="syt_MY_SECRET_TOKEN"
# An OpenAI API access key
OPENAI_API_KEY="my-secret-openai-api-key"(More configuration options will be added in the future.)
Finally, run the bot:
poetry run matrix-ai-assistantThis is written in python. Currently the code base is messy and I want to rewrite everything in golang. See the golang branch.
Here is a list of possible future improvements: