Fighting isolation using a mental health chatbot [prolog implementation]

Lisieux del Rocío Serrano Paz
6 min readMay 4, 2021

Oropeza A., Serrano L., Computer System Engineering Students of Tecnológico de Monterrey. Programming Language Course.

Introduction

After more than a year in pandemic isolation, we have had to overcome new challenges in our lifestyle. Although we have progressed with many home office techniques, we still have done so little for one silent threat: mental health fallout.

Photo taken by Sergey Semenov

Dr. Debanjan Banerjee, member of the National Institute of Mental Health and Neurosciences (NIMHANS) in Bangali warn us:

[1] “…the psychological impact of the illness is largely neglected. Pandemics like this, are not just a medical phenomenon; they tend to affect quality of life in an individual and as a whole, causing social dysfunction. … As the global prevalence increases, people start hoarding medical supplies, isolate themselves physically, restrict social interaction and enter into a constant state of health-anxiety even over mild conditions that can mimic the illness…”

Which implies that even after we can reach 70% of immunity of the global population, our social and emotional skills must be taken into account if we want to really reach a new, healthy, normality.

Photo taken by Soumen Hazra

Furthermore, in a recently published Opinion piece in Time Magazine, UN Secretary-General Antonio Guterres, stressed the cumulative impact of stress, grief, and anxiety.

[2] “Unless we act now to address the mental health needs associated with the pandemic, there will be enormous long-term consequences for families, communities and societies.”

Infographic made by Alonso Oropeza in Canvas.

This lead us to an opportunity, to intervene by combining [7]professional studies and logical components.

Solution

Given that there is a growing need for access to therapy and low support from social programs; we decided to create a solution that was relatively accessible (meaning they would only need a computer) and although it could not replace a therapist, it could help to provide emotional support effectively to those in need.

We want to test whether it is possible to automate this process, using the prolog programming language, making use of Natural Language Processing and the cognitive-behavioral therapy algorithm.

That’s when we started our research, and we found out it all started in the 60’s with Eliza…

Eliza embedded Youtube video.

As it is shown in the video, Eliza was one of the first chatbots to use a NPL (natural language processing), it was so revolutionary that people really believed they were talking to a real person.

Nowadays, chatbots are quite popular. Most of them use Natural Language Processing providing customer services, leisure, and automated processes. [6]The demand for emotional chatbots has grown in the recent years. The examples found include applications for mobile devices like: Woebot and Wysa; Joyable and Talkspace work as web applications.

Our project began. With brainstorm ideas we portray several diagrams until we reached the one that would be able to replicate the process of cognitive behavioral therapy:

Diagram made by Alonso Oropeza in Miro.

If you want to see the development process with high level of detail, feel free to visit our architecture handbook.

Without further ado, let’s see how you can run the code.

Setup

  1. Download SWI-Prolog or go to SWISH on your web browser.
  2. Download the latest stable version from the repository, save it with .pl extension.
  3. Load the file into the IDE.
  4. Run the code by typing the rule eliza.
Screenshot on how to run the code.

Results

This is how our mental health chatbot compares to other state-of-the-art platforms.

Comparative table made by Alonso Oropeza

The following graphs come from the beta testers program, which evaluates the psychological approach, user experience and clarity & coherence of the program.

Psychological approach rating
User experience rating
Clarity & coherence rating

Finally, this is how the program performs in the end-to-end testing

versions (documented) tested
IDE used for testing
Most common crashes

Conclusions

Although cognitive behavioral therapy (CBT) allows us to “hack” our emotions, we believe that it is very daring to say that it can replace professional therapy. As observed in the results, most of the competition makes use of the CBT, and they handle memorization to a lesser or greater extent to keep the user’s progress.

Although certified therapy is the best, it is also the most expensive. Even so, the tact and compassion that a human being has when talking about feelings, remains irreplaceable by the algorithms presented. Their weakness is precisely that they feel scripted, monotonous and paradoxically robotic.

From the beta testers we know an opportunity area is to improve user’s experience.This could be done using a framework like Jiprolog, which mixes Java and Prolog.

As shown in the testing, the most used version was the v1.2. Information was gathered from the crash reports and the beta testers program, and patches were made. The v1.3 is more stable, has better grammar, bug fixes and a bigger knowledge base.

Regardless of which tool is chosen, recognizing that we are the owners of our thoughts and how we interpret any situation can help us to have better control of our emotions.

References

[1] Banerjee D. (2020). The COVID-19 outbreak: Crucial role the psychiatrists can play. Asian journal of psychiatry, 50, 102014. https://doi.org/10.1016/j.ajp.2020.102014

[2] Petsanis, K. (2020, May 29). Facing mental health fallout from the coronavirus pandemic. World Health Organization. https://www.who.int/news-room/feature-stories/detail/facing-mental-health-fallout-from-the-coronavirus-pandemic.

[3] Shum, H.-yeung, He, X.-dong, & Li, D. (2018, January 8). From Eliza to XiaoIce: challenges and opportunities with social chatbots. Frontiers of Information Technology & Electronic Engineering. https://link.springer.com/article/10.1631/FITEE.1700826.

[4] World Health Organization. (2020, October 5). COVID-19 disrupting mental health services in most countries, WHO survey. World Health Organization. https://www.who.int/news/item/05-10-2020-covid-19-disrupting-mental-health-services-in-most-countries-who-survey.

[5] World Health Organization. (2021, April 1). Living with the Times: new toolkit helps older adults maintain good mental health and wellbeing during the COVID-19 pandemic. World Health Organization. https://www.who.int/news/item/01-04-2021-living-with-the-times-new-toolkit-helps-older-adults-maintain-good-mental-health-and-wellbeing-during-the-covid-19-pandemic.

[6] Hoermann H, et al. (2017). Application of synchronous text-based dialogue systems in mental health interventions: Systematic review. DOI:
10.2196/jmir.7023

[7]Craske, M. G. (2010). Theories of psychotherapy. Cognitive–behavioral therapy. American Psychological Association.

--

--