2024-10-26 16:47:16 +02:00
# Setting up matrix-bot-chatgpt (optional, unmaintained)
2023-01-02 19:16:38 +01:00
2024-10-28 08:33:35 +01: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 ](https://github.com/etkecc/baibot ), which can be installed using [this playbook ](configuring-playbook-bot-baibot.md ). Consider using that bot instead of this one.
2024-10-26 14:34:25 +02:00
2023-01-02 19:16:38 +01:00
The playbook can install and configure [matrix-chatgpt-bot ](https://github.com/matrixgpt/matrix-chatgpt-bot ) for you.
2023-01-10 16:22:54 +01:00
Talk to [ChatGPT ](https://openai.com/blog/chatgpt/ ) via your favourite Matrix client!
2023-01-02 19:16:38 +01:00
2024-12-04 03:57:15 +01:00
## Register the bot account
2023-01-02 19:16:38 +01:00
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.
2024-12-22 06:59:40 +01:00
Generate a strong password for the bot. You can create one with a command like `pwgen -s 64 1` .
2023-01-02 19:16:38 +01:00
You can use the playbook to [register a new user ](registering-users.md ):
2024-11-28 10:33:56 +01:00
```sh
2023-01-02 19:16:38 +01:00
ansible-playbook -i inventory/hosts setup.yml --extra-vars='username=bot.chatgpt password=PASSWORD_FOR_THE_BOT admin=no' --tags=register-user
```
2024-12-04 03:57:15 +01:00
## Get an access token and create encryption keys
2023-01-02 19:16:38 +01:00
Refer to the documentation on [how to obtain an access token ](obtaining-access-tokens.md ).
2024-11-07 11:04:51 +01: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-05-29 19:05:05 +02:00
2024-12-04 03:57:15 +01:00
## Adjusting the playbook configuration
2023-01-02 19:16:38 +01:00
2024-10-17 15:17:56 +02:00
Add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file (adapt to your needs):
2023-01-02 19:16:38 +01:00
```yaml
matrix_bot_chatgpt_enabled: true
2023-01-10 16:26:59 +01:00
2023-02-09 23:14:09 +01:00
# Obtain a new API key from https://platform.openai.com/account/api-keys
matrix_bot_chatgpt_openai_api_key: ''
2023-01-10 16:26:59 +01:00
# This is the default username
# matrix_bot_chatgpt_matrix_bot_username_localpart: 'bot.chatgpt'
2023-01-02 19:16:38 +01: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 04:50:05 +02: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 19:16:38 +01:00
```
You will need to get tokens for ChatGPT.
2024-12-04 03:57:15 +01:00
## Installing
2023-01-02 19:16:38 +01:00
2024-12-01 08:42:30 +01:00
After configuring the playbook, run it with [playbook tags ](playbook-tags.md ) as below:
2023-01-02 19:16:38 +01:00
2024-12-01 08:42:30 +01:00
<!-- NOTE: let this conservative command run (instead of install - all) to make it clear that failure of the command means something is clearly broken. -->
2023-01-02 19:16:38 +01:00
```sh
2024-12-01 08:42:30 +01:00
ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-users-created,start
2023-01-02 19:16:38 +01:00
```
2024-12-01 08:42:30 +01:00
**Notes**:
- The `ensure-matrix-users-created` playbook tag makes the playbook automatically create the bot's user account.
Edit installing instructions (#3844)
* Replace "just run-tags install-all/setup-all,start" with "just install-all/setup-all"
Thanks to the tip by Slavi that the overhead of ensure-matrix-users-created is negligible.
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
* Edit installing instructions
- Move the anchor links to docs/just.md
- Add note about running "ensure-matrix-users-created" tags, if ansible-playbook's tags not "setup-all,ensure-matrix-users-created,start", ie. either "setup-all,start", "setup-email2matrix,start", "setup-aux-files,setup-corporal,start", or "setup-matrix-user-verification-service,start"
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
* Update descriptions about installation
- Introduce the most conservative and stable raw ansible-playbook command.
- Introduce the just commands on installing.md and maintenance-upgrading-services.md, not on quick-start.md, since it is too early for quick start guide readers who are just starting to climb learning curve to use the shortcuts.
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
* Update docs/configuring-playbook-etherpad.md: remove the note about ensure-matrix-users-created
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
---------
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
Co-authored-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
2024-12-01 16:04:54 +01:00
- The shortcut commands with the [`just` program ](just.md ) are also available: `just install-all` or `just setup-all`
2024-12-01 08:42:30 +01:00
2024-12-02 06:29:44 +01:00
`just install-all` is useful for maintaining your setup quickly ([2x-5x faster](../CHANGELOG.md#2x-5x-performance-improvements-in-playbook-runtime) than `just setup-all` ) when its components remain unchanged. If you adjust your `vars.yml` to remove other components, you'd need to run `just setup-all` , or these components will still remain installed.
2023-01-02 19:16:38 +01:00
## Usage
2024-12-20 14:20:04 +01:00
To use the bot, invite it to the room you specified on your `vars.yml` file (`/invite @bot .chatgpt:example.com` where `example.com` is your base domain, not the `matrix.` domain).
After the bot joins the room, you can send a message to it. When you do so, use the prefix if you configured it or mention the bot.
2023-01-02 19:16:38 +01:00
You can also refer to the upstream [documentation ](https://github.com/matrixgpt/matrix-chatgpt-bot ).