There was someone I knew in high school; he and I weren’t all that close, but we shared a larger group of friends. I began to notice some changes in him as time progressed; he would withdraw from our friend group more often, and he stopped consistently showing up to class. Worried about him, I messaged him on Discord one day to ask how he was doing. We ended up talking for hours about what had been bothering him, and over the next few weeks, we would frequently message back and forth. He recently let me know how much it meant to him that someone was willing to listen in his time of need.

Plenty of people in the same situation as my friend might not be so lucky. Life is stressful, social media seems designed to feed self-esteem problems, and the pandemic starved many of us of routine, everyday social interaction; yet, so many of us have no outlet to express these issues and receive support. When the hackathon commenced, I told my teammates about this experience with my friend, and we decided to create something that could ensure nobody has to hold the weight of their struggles alone. We created Wellness Bot, a project that allows anonymous conversation between someone needing to talk and someone willing to listen. In addition, the bot detects those who are most at risk based on the messages they send and reaches out to these people with information about our services and an advisal to seek professional help.

What it does

Wellness Bot is a Discord bot with the primary goal of keeping servers and the people in them safe. Using a machine learning algorithm, Wellness Bot scans through every message sent in a server and calculates the probability of how likely the user is to be at risk of mental unwellness. If the bot determines that the user who sent the message may not be doing well, it will send the person a direct message to check in if they are okay.

Additionally, Wellness Bot includes an anonymous chat feature, where users can speak with mentors about their mental health struggles or sign up to become mentors themselves. The bot acts as a middleman, keeping the identity of the user and mentor completely confidential and allowing people to speak freely about their struggles. When a user requests to talk with a mentor, the bot matches them with a mentor who is free to chat. And through Wellness Bot, mentors can set when they are not available using do not disturb commands.

Wellness Bot has a website that details its functions, features, and feedback and provides a link to invite the bot to a server.

How we built it

Wellness Bot consists of four main components: the bot itself, the server backend, the website, and a machine learning algorithm.

The Discord bot was created in Javascript using the discord.js library. The contents of users’ messages are checked for if they match predefined commands, running a command’s corresponding function if a match is found. The bot sends and accesses information about available mentors, ongoing conversations and feedback through HTTP requests to the server backend’s API, using the node-fetch library. Additionally, the bot sends each new message to the backend for said message to be evaluated by the machine learning algorithm. The bot then communicates with users by sending Discord messages, either to respond to commands, provide support for those whose messages have been detected to be concerning, and facilitate anonymous conversations between two people.

The backend server was coded in javascript, using the express.js library to handle API requests as well as serve our static website. The API server receives requests from the discord bot, and responds to them appropriately. A Google Sheets spreadsheet was used for a database, due to its simplicity and ease of use. The entire backed server was put into a Docker container, which makes the application easier to deploy and scale. The library chrono-node was used to parse the date for the do not disturb functionality, which provides natural language processing capabilities. The API also acted as a proxy server for machine-learning requests, as the tensorflow python process runs its own http server using flask.

The machine learning model was built in python, using word-embedding and a bag-of-words model in TensorFlow Keras to perform a binary classification on any message, namely whether or not that message is indicative of mental unwellness. It was trained on a dataset of 1,500 messages with a 50-50 split regarding being mentally healthy/not mentally healthy and was scraped from discord servers and a dataset we found on Kaggle. The algorithm was implemented by using the model as a function in a python script, and that function was called by the backend every time a message was sent. If the model deemed the message to be concerning, Wellness Bot would then receive a response to its HTTP request informing it of such and then send a private message to the user that authored the concerning message.

The website was made with basic HTML, CSS, and vanilla JavaScript. An animate-on-scroll library was also added to improve the overall flow of the website and to add a unique effect when scrolling through the page.

Challenges we ran into

The biggest challenge we ran into was with the machine learning algorithm. While training the neural network, a lack of varied data was a significant challenge as, by nature of the sensitivity of the topic, there were very few public datasets of messages that truly indicated mental unwellness. The one we could find, however, was riddled with inconsistencies, so we had to create complex scripts to parse through the dataset and prepare it for training.

Furthermore, we had difficulty converting the TensorFlow Keras model in python to javascript so that it could be used directly in our js backend. As a result, we used a python script with the TensorFlow model, which ran an http server using flask. The backend would make a request to the python script every time a message was sent, returning whether or not that message was concerning.

Accomplishments that we're proud of

This was the first time that any of us have implemented a machine learning model in a deployable project, and to have it work seamlessly and effectively on such a large scale is something that we are immensely proud of. Over the course of this hackathon, many of us were unfamiliar with the technologies that we were to use, but despite this, we were able to learn, engineer, and integrate our technologies to work harmoniously with each other. Furthermore, we are not only proud, but deeply satisfied with the potential this project has to impact vulnerable groups who have been historically neglected. Wellness Bot has the potential to truly impact the lives of millions of people around the world. These are the people who often most need, but don’t receive, the utmost love, care, and attention.

What we learned

For three people in our four-person team, this was the first hackathon we participated in. Working on a collaborative project with multiple moving parts was new to us, so spending time creating Wellness Bot allowed us to become acclimated with the git workflow and forced us to add communication to our repertoire of programming skills. We also learned a lot about the languages we used to create the individual components of this project; some of us took on libraries and frameworks we weren’t very familiar with and built our skills through the completion of tasks. For example, some of us were unfamiliar with HTTP requests before this hackathon, and through constantly integrating this feature into our programs, it became much more intuitive.

What's next for Wellness Bot

Our primary next steps for Wellness Bot includes increasing the accuracy of the machine learning algorithm and implementing a verification system for our mentors. To improve our Bot’s accuracy, training an RNN would be the next best step, allowing the algorithm to also take into account the order of words, rather than just their existence as is true with bag-of-words models.

Additionally, we would like to implement a verification system for people who sign up to be mentors. Currently, we are running on a trust system where anyone who wants to volunteer can, which runs the risk of attracting people who don’t have the best intentions for our users. To prevent this, a verification system will be introduced to screen through volunteers, and improvements will be made to the current mentor server. Too often, mental health services are denied the urgency and accessibility of other human rights, hidden behind exorbitant prices. We hope to keep Wellness Bot as affordable as possible for the individuals who need it and set forth a larger shift in the affordability of support.

Built With

Share this project: