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.