This natural language processing matrix-chatbot is designed for the messenger Element (previously named Riot.im) and is based on the matrix-nio client libary. The chatbot can be used as a digital learning assistant for students and answers lecture related questions with references to slides. The chatbot communicates in english and german. Knowledge extension is achieved by simply adding new rules in predetermined files that serve as a data basis for the chatbot. The application also offers a statistical overview of frequently asked topics, which can be queried directly via the chatbot.
- python version 3.5+
- pip3
- docker.io
- docker-compose
- Create a new Element user account manually.
- Customize the connection parameters of the database and Element account in config.yaml
- To add chatbot knowledge of a new lecture script, change the URL, if necessary the URL prefix and add the module name all in index_evaluation.py.
- To expand the chatbot's data basis, add new rules to small_talk_evaluation.py and organisational_document.py.
- For organisational documents also add the concerning module name in organisational_document.py.
- Clone this repository and navigate into the repoistory folder
- Install all the requirements
pip3 install -r requirements.txt
- Add all the nltk data
python3 -m nltk.downloader all
- Start the docker container
docker-compose up -d
- Navgiate into folder models and create all the tables
python3 database.py
- Add data basis by entering the folder modules and call the following scripts
python3 index_evaluation.py python3 organisation_evaluation.py python3 small_talk_evaluation.py
- Start the chatbot
python3 main.py
After starting the chatbot any user may be able to communicate with the bot. In the Element messenger, the chatbot can be added to a room via matrix ID.
The support is still a work in progress for the project. Messages sent to an encrypted room cannot be handled yet. For future development, this is how matrix-nio with E2EE support can be downloaded on Ubuntu.
- Install the latest version of python-olm
For e2e support, installing the libolm C libary is recommended
git clone https://gitlab.matrix.org/matrix-org/olm.git sudo make sudo make install sudo ldcfongig
- Install matrix-nio, if you want e2e support call
pip3 install "matrix-nio[e2e]"
The software architecture is modular and consists of seven modules.
Chabot data is being anonymized and stored in 7 tables in a relational PostgreSQL database. The database is accessible via docker container.
This sequence diagram describes how an incoming text message is processed by the chatbot to generate a response fitting the user's message.
Test messages are processed with an nlp component. The processing is necessary to standardize the messages which allows the chatbot to later find fitting entries (rules) from the data basis.
MIT licensed
Copyright (C) 2020 Jonathan Quade