Skip to content

A Telegram bot based on aiogram and MongoDB. The primary mission of the bot is to help people (especially developers) to prevent burnout and depression. Through the bot, users can pass evidence-based psychological tests and monitor the changes dynamic of their mental state.

License

Notifications You must be signed in to change notification settings

astroevska/psybot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Psychological Bot

A Telegram bot based on aiogram and aiohttp with cloud-based NoSQL-database MongoDB implemented through pymongo package. The solution has REST API service and is based on asynchronous patterns. Also, the bot is written with static typing for self-checking and improving the readability of the code.

Features

  • 📝 Passing tests
  • Reminders (bot can remind you to pass a test by your self-defined time)
  • 📊 Statistics of your results
  • 🌍 EN/UA/RU multilanguage supporting
  • 🐳 Dockerized
  • 📡 Full-provided REST API
  • 🎛 Full testing coverage provided by pytest and unittest libraties.

Details

The main mission of the bot - helping people (especially developers) to prevent burnout and depression. The bot allows:

  • passing the evidence based psychological assessments (currently, only The Beck Depression Inventory Test BDI-II) with a user-friendly interface based on the Telegram inline keyboard.
  • viewing dynamics changes (by plots implemented by matplotlib and seaborn) of a user's mental condition (time-series of tests results) to control it and notice patterns.
  • getting human-readable interpretations of tests result for a better understanding own mental condition.

Requirements

  1. Python3.9 or newer.
  2. Pyenv
  3. MongoDB Atlas
  4. Docker

Installation

I created a Bash script that provides a simple and quick initialization of the bot. The script creates and activates a virtual environment or docker container, installs packages from requirements.txt, replaces constants with private access tokens for Telegram Bot API and MongoDB, and starts the bot.

  • YOUR_TELEGRAM_BOT_TOKEN is a Telegram Bot Access Token. There is a getting token here through creating a new Telegram bot.
  • YOUR_MONGO_DB_CONNECTION_STRING is a connection string for MongoDB that is accessible after the MongoDB Cluster creation. See details.

At first, you need to get psybot's codebase.

$ git clone https://github.com/annagerd/psybot.git
$ cd psybot

Then there are two ways to start the bot: natively by Python or by Docker.

Python launching

  1. The only thing you need is to run an init.sh file by the following command in your CLI:
$ ./init.sh python YOUR_TELEGRAM_BOT_TOKEN YOUR_MONGO_DB_CONNECTION_STRING

By Docker

  1. If you haven't installed Docker, install it.
  2. Run the Docker
  3. Run an init.sh file by the following command in your CLI.
$ ./init.sh docker YOUR_TELEGRAM_BOT_TOKEN YOUR_MONGO_DB_CONNECTION_STRING

The bot should start if you used the correct syntax and passed the right data. Congrats!

Goals

  • Deployment (Heroku, Vercel or DigitalOcean).
  • Add more tests (depression, anxiety, burnout and etc).
  • Start to create an IT ecosystem of psychological self-care with the bot as a part of it.

References

  • Aiogram 3 docs. This version is used in my project.
  • Aiogram 2 docs. I don't use this version here, but the docs of the second version are also useful because of a lot of useful information and advices that is still actual for also the third version.
  • Aiohttp docs. This library is a core library of aiogram web server, and it's also used here for REST API endpoints.
  • Docker docs. The bot is dockerized to be independent of environment.
  • Asyncio and threading libraries docs. These libraries are used for:
    • reminding users;
    • parallel launching of the bot and the REST API server.
  • MongoDB docs. Full MongoDB docs.
  • MongoDB Python Start Guide. Simple instructions about using MongoDB with Python programming language.
  • MongoDB References. References that can help you to work with Mongo API.
  • Matplotlib References. Full Matplotlib API docs. It will be useful for the customization of the bot's plots.
  • Static Typing in Python. It will be useful for dynamic typing languages users who want to understand static typing in Python.
  • Telegram Bot API docs. Official Bot API docs provided by the Telegram.

About

A Telegram bot based on aiogram and MongoDB. The primary mission of the bot is to help people (especially developers) to prevent burnout and depression. Through the bot, users can pass evidence-based psychological tests and monitor the changes dynamic of their mental state.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published