2024-10-22 17:36:24 +00:00
# Setting up matrix-bot-chatgpt (optional)
2023-01-02 18:16:38 +00:00
The playbook can install and configure [matrix-chatgpt-bot ](https://github.com/matrixgpt/matrix-chatgpt-bot ) for you.
2023-01-10 15:22:54 +00:00
Talk to [ChatGPT ](https://openai.com/blog/chatgpt/ ) via your favourite Matrix client!
2023-01-02 18:16:38 +00:00
2024-09-12 12:19:40 +00:00
**Note**: [matrix-chatgpt-bot ](https://github.com/matrixgpt/matrix-chatgpt-bot ) is now an archived (**unmaintained**) project. Talking to ChatGPT (and many other LLM providers) can happen via the much more featureful [baibot ](./configuring-playbook-bot-baibot.md ) bot supported by the playbook.
2023-01-02 18:16:38 +00:00
## 1. Register the bot account
The playbook does not automatically create users for you. The bot requires an access token to be able to connect to your homeserver.
You **need to register the bot user manually** before setting up the bot.
Choose a strong password for the bot. You can generate a good password with a command like this: `pwgen -s 64 1` .
You can use the playbook to [register a new user ](registering-users.md ):
```
ansible-playbook -i inventory/hosts setup.yml --extra-vars='username=bot.chatgpt password=PASSWORD_FOR_THE_BOT admin=no' --tags=register-user
```
2023-05-29 17:05:05 +00:00
## 2. Get an access token and create encryption keys
2023-01-02 18:16:38 +00:00
Refer to the documentation on [how to obtain an access token ](obtaining-access-tokens.md ).
2023-05-29 17:05:05 +00:00
To make sure the bot can read encrypted messages, it will need an encryption key, just like any other new user. While obtaining the access token, follow the prompts to setup a backup key. More information can be found in the [element documentation ](https://element.io/help#encryption6 ).
2023-01-02 18:16:38 +00:00
## 3. Adjusting the playbook configuration
2024-10-17 13:17:56 +00:00
Add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file (adapt to your needs):
2023-01-02 18:16:38 +00:00
```yaml
matrix_bot_chatgpt_enabled: true
2023-01-10 15:26:59 +00:00
2023-02-09 22:14:09 +00:00
# Obtain a new API key from https://platform.openai.com/account/api-keys
matrix_bot_chatgpt_openai_api_key: ''
2023-01-10 15:26:59 +00:00
# This is the default username
# matrix_bot_chatgpt_matrix_bot_username_localpart: 'bot.chatgpt'
2023-01-02 18:16:38 +00:00
# Matrix access token (from bot user above)
# see: https://webapps.stackexchange.com/questions/131056/how-to-get-an-access-token-for-element-riot-matrix
matrix_bot_chatgpt_matrix_access_token: ''
2023-07-30 02:50:05 +00:00
# Configuring the system promt used, needed if the bot is used for special tasks.
# More information: https://github.com/mustvlad/ChatGPT-System-Prompts
matrix_bot_chatgpt_matrix_bot_prompt_prefix: 'Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.'
2023-01-02 18:16:38 +00:00
```
You will need to get tokens for ChatGPT.
## 4. Installing
2024-10-13 02:50:04 +00:00
After configuring the playbook, run the [installation ](installing.md ) command:
2023-01-02 18:16:38 +00:00
```sh
2023-01-10 15:26:59 +00:00
ansible-playbook -i inventory/hosts setup.yml --tags=install-all,start
2023-01-02 18:16:38 +00:00
```
## Usage
2024-10-17 13:17:56 +00:00
To use the bot, invite the `@bot.chatgpt:example.com` to the room you specified in a config, after that start speaking to it, use the prefix if you configured one or mention the bot.
2023-01-02 18:16:38 +00:00
You can also refer to the upstream [documentation ](https://github.com/matrixgpt/matrix-chatgpt-bot ).