Per default, whoever knows the name of your bot can add it to their rooms and start chatting. Access can be restricted by setting `MATRIX_BLACKLIST` or `MATRIX_WHISTLIST` in your `.env` file. When using a self-hosted setup, you could wildcard all your user by adding `MATRIX_WHITELIST=:anotherhomeserver.example` and change it to your homeserver address.
- You need to have an account at [openai.com. ](https://openai.com/). Create a [API Key](https://platform.openai.com/account/api-keys). Then, set `OPENAI_API_KEY` in your `.env` file
- You might want to change to chat-model by setting the `CHATGPT_MODEL` in your `.env` file. The model currently defaults to `text-chat-davinci-002-20221122`. Check the [node-chatgpt-api](https://github.com/waylaidwanderer/node-chatgpt-api) repository for keeping track of the models.
At first run, the bot outputs `MATRIX_ACCESS_TOKEN` to the console if it is not already set but `MATRIX_BOT_USERNAME`&`MATRIX_BOT_PASSWORD` are.
You must set `MATRIX_ACCESS_TOKEN` to use this token. Do not use it with any other client. Also, do not use an access token extracted via Element. This can cause issues with encryption later on.
You no longer need `MATRIX_BOT_PASSWORD` set but you can leave it if you want.
Note: In order to see the output of your console you need to run `docker logs matrix-chatgpt-bot`
## with Docker Compose
You can also simply use a docker-compose file. You only need to copy the content below and save it in a file named `docker-compose.yml`. Either with a self-build image (run `docker build . -t matrix-chatgpt-bot` from your local git repo location) or with the latest stable release as pre-build package from this repo, which is the **recommended** way. The script will look for the `.env` file in the same folder as the `docker-compose.yml`. The key storage folder `storage` will be created in the same folder as well. Adjust the locations to your needs.
**Important**: It is strongly recommended to run this package under Docker to not need to install various dependencies manually.
Nevertheless, you can also run it by using the package manager yarn (get it via `apt install -y yarn`). You might also need to have a newer version of Node.js and other missing packages.
- The bot replies in a thread. If you want to keep the context you need to reply to this thread or the bot will think its a new conversation. "Threads" were recently an experimental feature so you may need to activate it in your clients settings (e.g. in Element in the "lab"-section).
- There is support to set the context to work at the room level, the thread level or both (threads fork the conversation from the main room)
- The `CHATGPT_MODEL` environment sets the used model. As of writing the default uses ChatGPT from late 2022 which works fine, however we can't tell if OpenAI decides to remove the model. If so, you can always change the model variable to `text-davinci-003` or any other of the [supported models](https://platform.openai.com/docs/models/gpt-3). Keep in mind that that these models are not free and will cost you OpenAI credits.
- Don't use a `MATRIX_ACCESS_TOKEN` extracted via Element-App, use the generated token from the bot based on your `MATRIX_BOT_USERNAME`&`MATRIX_BOT_PASSWORD` set in the `env`file. It will be visible in the console at start up if the `MATRIX_ACCESS_TOKEN` is not already set:
1) Remove the `MATRIX_ACCESS_TOKEN` from the `env` file and make sure `MATRIX_BOT_USERNAME`&`MATRIX_BOT_PASSWORD` are set
2) Re-run the bot
3) Copy the token from console output to your `env` file
- If all fails, you can always reset your key storage. It's important to exercise all of the following steps, because any remaining data could lead to the next encryption error. Once everything is working, make sure to not touch the "storage" folder anymore:
## I just want to chat with the bot and don't want to deal with encryption problems
- Set `MATRIX_ENCRYPTION=false` in your env-file and restart the bot. If it previously was running with encryption switched on, you need to create a new room with the bot as encryption can't be switched off once it was activated.
## I'm getting a "{ errcode: 'M_NOT_FOUND', error: 'Event not found.' }" in my log files, do I need to worry?
- So far, its not known to cause issues, you can safely ignore it.
## What to do if I get a TimeoutError, e.g. "TimeoutError: Navigation timeout of 30000 ms exceeded"?
This can happen if your bot can't reach the openai server.
- Make sure that your machine can reach the internet (e.g. using curl: `curl -I www.google.com` should give you a useful output (not "Could not resolve host")
- When using docker, you first need to get inside the container via `docker exec -it matrix-chatgpt-bot bash` and get the curl package `apt-get update && apt install -y curl`). You can then run the command from within the container.
- Verify that you are using a google account and 2FA is **NOT** activated.
## ChatGPT is at capacity right now?
There are multiple ways out there on what to do, so see this just as some ideas
- If you can't login via website, try clearing your browser cache by pressing "shift" and reload the OpenAI page https://chat.openai.com
- If your bot can't connect, just be a bit patient, it typically does not take long until it's back
## How do I know that the bot is running succesfully?
Once the bot has started succesfully, it will output the following information to your console.