School of Science and Technology 科技學院
Computing Programmes 電腦學系

Youth Services Discord Chatbot

Andy CHAN HO MING, Eric CHAN HOI WAI, Jayden CHAN KWOK FUNG, Ken YEUNG WUN TAK

ProgrammeBachelor of Computing with Honours in Internet Technology

Bachelor of Science with Honours in Computer Science
SupervisorDr. Keith Lee
AreasIntelligent Applications
Year of Completion2023

Objectives

Hidden youth, who avoid social situations and gatherings, make up about 2% of the population and are becoming more common in Hong Kong. The COVID-19 pandemic has made the phenomenon more serious, as people are forced to stay at home. 6PM, an online support team from St. James’ Settlement in Hong Kong, helps hidden youth solve emotional problems and provides online resources such as counseling and gatherings. They have provided a Discord platform for events and to connect with hidden youth.

Project Aim

Hidden youth who stay at home for prolonged periods experience a deterioration of their social and communication skills, leading to disconnection and nervousness. To address this, we partnered with SJS to develop a Discord bot and web application using natural language processing (NLP). The bot can communicate more humanely, helping hidden youth train their social skills and become more confident. The web application reduces analysis and management time, replacing the use of Excel. Our goal is to help hidden youth become more outgoing and sociable, improving their mental health in the long term.

Project Objectives

We focus on the following objectives, derived from our functions, to help meet the aim of our goal:

  1. Bringing informative news
  2. Chatting with hidden youth
  3. Reducing social workers’ workload
  4. Promoting 6PM
  5. Evaluating the system.

The chatbot’s objectives include bringing informative news and chatting with hidden youth to train their social skills and detect emotions. It can intervene in disputes and reduce social workers’ workload by substituting some of their tasks. A web application is available for social workers to analyze organized events and group chat logs for emotion analysis. Promoting 6PM can be done by reposting information on Discord. The evaluation process involves granting access to a predetermined number of users to evaluate the bot’s functionality and a comprehensive Google form for feedback. Social workers assess the chatbot and web application’s user-friendliness, implementations, and features.

Videos

Demonstration Video

Presentation Video

Methodologies and Technologies used

Overview of Solution

Figure 1: Architecture of Discord Chatbot and web application

To tackle the problems mentioned previously, a Discord chatbot and a web application were designed. The Discord chatbot included basic conversational functions, the ability to detect user emotions, and the ability to join events. The web application included event creation, posting events on Discord, and chatlog analysis. Pycord with the Python programming language was mainly used to develop the Discord chatbot, which could be classified into server-side and client-side. An additional web application was developed using the PHP programming language.

Architecture or High-Level System Design

 

On the server side:

 

Hosting Discord chatbot

  • NLP processing: Before the user received a reply from the Discord server, the reply was produced from the NLP training model and compared with the probability from the tag in the data.pth file.
  • Emotion detection: The emotion of the user’s text message was outputted from a pre-trained text-based emotion model. The chatbot sent the user a direct message through the Discord Server if they sent sad messages more than three times. If the text message was angry, the chatbot sent a calm down message through the Discord Server.
  • Apply Event: After the event was posted on the Discord channel created by the social worker, users could apply for the event. The application data was sent to St. James’ server and saved in the database (server-side) through the Discord Server. The social worker decided who could join the event and returned the status of the application through the API. The Discord server (client-side) sent a confirmation or rejection message to the user. Once the user confirmed, it was sent back to the server, and the status changed to confirmed.
  • FAQ: The organization’s data was initially saved in the database of St. James’ server. The data was retrieved from the database before it was sent back to Discord’s server.
  • Repost from social media websites: When any latest posts were detected from Facebook by St. James’ server, the Discord server sent the post, and then the database in St. James’ server was updated.

Figure 2: Overview of the Discord Bot’s functionality

Figure 3: Dialog Management Flowchart with NLP

Figure 4: Flowchart of Emotion Detection

Hosting web application:

  • The web application usually wrote into the database.
  • Create activity: When an activity was created by the social worker on the web application, the database was also updated.
  • Create event: When an event was created by the social worker on the admin web page, the database was also updated.
  • Login: If the social worker changed the password of their account on the web application, the database was also updated.

Figure 5: Overview of the Web Application functionality

Figure 6: Overview of the Web Application functionality

Hosting API:

  • There were two API functions sent to the Discord server:
    1.  An API request with the event ID was sent by the web application to send an event post to the Discord server if a social worker posted the event to the Discord channel. The API connected to a database to retrieve relevant information based on the event ID before sending an event post to the Discord server.
    2. An API request with the event ID was sent by the web application to send the information to the Discord Server after the social worker confirmed the applicant’s status of the event. The API connected to the database to retrieve the applicant’s Discord IDs based on the event ID before sending the information to the Discord Server. The Discord server sent a confirmation message to all members who applied for that event.

Figure 7: Sending application confirmation to user

On the client side:
  • There were two main users: social workers and Discord users.
  • Data from the database on the web application, such as retrieving the record of events, activity information, and chat log, was read by social workers.
  • Most of the Discord user’s functions, requests, and responses were done through the Discord Server. For example, if a user chatted with the chatbot, the Discord Server sent a request to St. James’ own server, then received a response. The Discord Server retrieved relevant data from the database depending on the function, converted the response into a message, and then replied to the user.

Implementation

As we were in the prototype stage, Docker containers were used. The advantages of using Docker included:

  • Simplicity and faster configurations (containerization)
  • Monitoring
  • Isolation (containers)
  • Scalability
  • Security (applications are isolated)
  • Flexible sharing (portable)
  • Support for multiple OS, e.g., Windows, macOS, Linux
  • Support for multiple Cloud platforms, e.g., Azure, AWS EC2, GCP
  • Productivity (DevOps CI/CD pipeline with Kubernetes)

Results (Prototype System Design)

Functionality Evaluation (6PM feedback)

Meetings were held with 6PM Organization to assess the concept and features of the web application and the Discord chatbot’s overall performance. They were satisfied with the features overall and impressed with the ability to create events, analyze chat, and detect user emotions when social workers were not around. Some additional suggestions were made, such as adding confirmation features to notify users of their event application.

Functionality Evaluation

Conclusion

The objectives of the Discord chatbot and web application were achieved. The chatbot was successful in providing informative news and promoting 6PM, but only partially satisfied the objective of chatting with hidden youth. The web application reduced social workers’ workload, especially in event organization. The improvements suggested in the evaluation were implemented in both the chatbot and web application, which improved the quality of service.

The chatbot’s interactive functions helped hidden youth become more engaged and interactive, which could alleviate the hidden youth phenomenon. The emotion detection function could detect negative messages and send emotional requests to social workers for follow-up or intervention. Users could also join activities posted by social workers from the web application. However, the NLP was limited to available datasets and needed to be updated manually, which could result in a loss of interest in interacting with the chatbot in the long run. Emotion detection was only capable of detecting emotions in simple sentences and could not detect complicated emotions.

To solve these problems, a better emotional model and NLP model should be used. Subscription paid services from Komprehend AI or BytesView could provide better performance of the emotion detection functionality. Subscription paid API services from OpenAI, such as GPT-3, could make extensive conversations and improve engagement and interaction with the chatbot.

The search event function of the web application could be improved by adding a description search to make it more efficient and convenient for social workers. Overall, the improvements suggested in the evaluation enhanced the quality of service of the chatbot and web application, benefiting hidden youth and social workers

Future Development

In the future, the following work could be done to improve our project:

  • Improve the chatting NLP model.
  • Link with other social media.
  • Apply a better pre-trained emotion model.
  • Run on SJS’s server.
Jonathan Chiu
Marketing Director
3DP Technology Limited

Jonathan handles all external affairs include business development, patents write up and public relations. He is frequently interviewed by media and is considered a pioneer in 3D printing products.

Krutz Cheuk
Biomedical Engineer
Hong Kong Sanatorium & Hospital

After graduating from OUHK, Krutz obtained an M.Sc. in Engineering Management from CityU. He is now completing his second master degree, M.Sc. in Biomedical Engineering, at CUHK. Krutz has a wide range of working experience. He has been with Siemens, VTech, and PCCW.

Hugo Leung
Software and Hardware Engineer
Innovation Team Company Limited

Hugo Leung Wai-yin, who graduated from his four-year programme in 2015, won the Best Paper Award for his ‘intelligent pill-dispenser’ design at the Institute of Electrical and Electronics Engineering’s International Conference on Consumer Electronics – China 2015.

The pill-dispenser alerts patients via sound and LED flashes to pre-set dosage and time intervals. Unlike units currently on the market, Hugo’s design connects to any mobile phone globally. In explaining how it works, he said: ‘There are three layers in the portable pillbox. The lowest level is a controller with various devices which can be connected to mobile phones in remote locations. Patients are alerted by a sound alarm and flashes. Should they fail to follow their prescribed regime, data can be sent via SMS to relatives and friends for follow up.’ The pill-dispenser has four medicine slots, plus a back-up with a LED alert, topped by a 500ml water bottle. It took Hugo three months of research and coding to complete his design, but he feels it was worth all his time and effort.

Hugo’s public examination results were disappointing and he was at a loss about his future before enrolling at the OUHK, which he now realizes was a major turning point in his life. He is grateful for the OUHK’s learning environment, its industry links and the positive guidance and encouragement from his teachers. The University is now exploring the commercial potential of his design with a pharmaceutical company. He hopes that this will benefit the elderly and chronically ill, as well as the society at large.

Soon after completing his studies, Hugo joined an automation technology company as an assistant engineer. He is responsible for the design and development of automation devices. The target is to minimize human labor and increase the quality of products. He is developing products which are used in various sections, including healthcare, manufacturing and consumer electronics.

Course Code Title Credits
  COMP S321F Advanced Database and Data Warehousing 5
  COMP S333F Advanced Programming and AI Algorithms 5
  COMP S351F Software Project Management 5
  COMP S362F Concurrent and Network Programming 5
  COMP S363F Distributed Systems and Parallel Computing 5
  COMP S382F Data Mining and Analytics 5
  COMP S390F Creative Programming for Games 5
  COMP S492F Machine Learning 5
  ELEC S305F Computer Networking 5
  ELEC S348F IOT Security 5
  ELEC S371F Digital Forensics 5
  ELEC S431F Blockchain Technologies 5
  ELEC S425F Computer and Network Security 5
 Course CodeTitleCredits
 ELEC S201FBasic Electronics5
 IT S290FHuman Computer Interaction & User Experience Design5
 STAT S251FStatistical Data Analysis5
 Course CodeTitleCredits
 COMPS333FAdvanced Programming and AI Algorithms5
 COMPS362FConcurrent and Network Programming5
 COMPS363FDistributed Systems and Parallel Computing5
 COMPS380FWeb Applications: Design and Development5
 COMPS381FServer-side Technologies and Cloud Computing5
 COMPS382FData Mining and Analytics5
 COMPS390FCreative Programming for Games5
 COMPS413FApplication Design and Development for Mobile Devices5
 COMPS492FMachine Learning5
 ELECS305FComputer Networking5
 ELECS363FAdvanced Computer Design5
 ELECS425FComputer and Network Security5