Matrix bot that generates messages based off of messages of other users using a neural network.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
array-in-a-matrix 03d928a3f0 removed size variable 7 months ago
.gitignore ignore AI related files 8 months ago
LICENSE Initial commit 8 months ago removed size variable 7 months ago
example.config.json removed size variable 7 months ago
index.js message counter for each room 7 months ago
package.json now using pythonshell lib 7 months ago
pnpm-lock.yaml now using pythonshell lib 7 months ago improvements 7 months ago


Matrix bot that generates messages based off of messages of other users using a neural network. The first Matrix AI?

Note: Project is still being developed and some functionality is not fully implemented yet.

Table of content


First install the needed using the instructions here. Then copy example.config.json and rename it config.json. Replace the items in angled brackets with their respective values of the bot account (e.g. replace <DOMAIN.TLD> with the homeserver url like or An explanation of each configurable string is located in configurations section of this document. To obtain the token of an account follow the instructions here.

Once the config file has been populated with valid data, execute the index.js file (Warning: executing for the first time will be slow.).

$ node index.js
<some warnings show up, ignore them>
Client has started!

List of directories and files created by the project and its dependencies:

  • aitextgen/
  • node_modules/
  • trained_model/
  • aitextgen.tokenizer.json
  • storage.json
  • training-matrix.txt


The bot has several commands:

► generate   ⇢     Generates a message in the room. 
► train      ⇢     Trains the AI's mini GPT-2 model.


The project is split into 2 parts index.js and The index.js file contains the code that interacts with the user on Matrix and sends text generated by the file.

Install matrix-bot-sdk and python-shell (JS):

> pnpm add matrix-bot-sdk
> pnpm add python-shell

Install aitextgen (PY):

> pip3 install aitextgen


Before a bot can be used the fields in the config.json file must be populated with valid information. Values in angled brackets (stared below) must be supplied before usage.

► homeserver*   ⇢     URL of the bot's homeserver.

► token*        ⇢     Account token used to sign in the bot.

► user*         ⇢     Account's User ID.

► file          ⇢     Path of file used for training the AI (.txt file only).

► prefix        ⇢     Bot listens to commands that start with this prefix.

► frequency     ⇢     How often the bot sends a message (keep high to prevent spam).

► retrain       ⇢      The bot retrains itself after this many extra lines of messages are recorded in the text file.

Using existing messages

If you do not want to wait until the bot creates its own dataset from new messages, you can export chat history of a room easily using Element. In this case, you will need to manually remove the time stamps from the text file then place the path of the file in the file variable in the configuration file.