├── .gitignore ├── README.md ├── app.py ├── config.yml ├── credentials.yml ├── domain.yml ├── endpoints.yml ├── rasa_bot ├── actions │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ └── actions.cpython-38.pyc │ └── actions.py ├── config.yml ├── credentials.yml ├── data │ ├── nlu.yml │ ├── rules.yml │ └── stories.yml ├── domain.yml ├── endpoints.yml └── tests │ └── test_stories.yml ├── requirements.txt └── templates ├── admin.html ├── chatbot.html └── index.html /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GopikaSenthilkumar/Sentiment-Analysis/2e3baf540c949df9636ace08f34bc262bf4da284/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mental Health Companion 2 | 3 | A web-based mental health support application that uses sentiment analysis to provide personalized emotional support, chat functionality, and video recommendations. 4 | 5 | ## Features 6 | 7 | - Modern login interface 8 | - Sentiment analysis for detecting user emotions 9 | - Personalized video recommendations based on mood 10 | - Real-time chat interface with emoji support 11 | - Admin panel for feedback management 12 | - Mobile-responsive design 13 | 14 | ## Technologies Used 15 | 16 | - Python Flask for backend 17 | - TextBlob for sentiment analysis 18 | - HTML, CSS, and JavaScript for frontend 19 | - Real-time feedback system 20 | - Video recommendation engine 21 | 22 | ## Installation 23 | 24 | 1. Clone this repository 25 | 2. Create a virtual environment: `python -m venv venv` 26 | 3. Activate the virtual environment: 27 | - Windows: `venv\Scripts\activate` 28 | - Unix/MacOS: `source venv/bin/activate` 29 | 4. Install dependencies: `pip install -r requirements.txt` 30 | 5. Run the application: `python app.py` 31 | 32 | ## Usage 33 | 34 | After starting the application, navigate to `http://localhost:5000` in your web browser to access the login page. 35 | 36 | - Login with username/password 37 | - Use the chat interface to communicate 38 | - Express your emotions using emoji buttons 39 | - View and click on video recommendations 40 | - Provide feedback that will be stored for admin review 41 | 42 | ## Admin Access 43 | 44 | To access the admin panel, use the following credentials: 45 | - Username: admin 46 | - Password: admin123 47 | 48 | Navigate to `/admin` to view user feedback with timestamps. -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify, render_template, redirect, url_for, session 2 | from textblob import TextBlob 3 | from datetime import datetime 4 | import re 5 | 6 | app = Flask(__name__) 7 | app.secret_key = "your_secret_key" 8 | 9 | # User Database 10 | users = { 11 | "admin": "admin123" 12 | } 13 | 14 | # In-Memory Feedback Storage (Replace with a database in production) 15 | feedback_list = [] 16 | 17 | # YouTube Video Recommendations with thumbnails and titles 18 | VIDEO_RECOMMENDATIONS = { 19 | "happy": { 20 | "url": "https://www.youtube.com/watch?v=FQDa6jJpmdA", 21 | "thumbnail": "https://img.youtube.com/vi/FQDa6jJpmdA/maxresdefault.jpg", 22 | "title": "Uplifting Music for Happy Mood" 23 | }, 24 | "sad": { 25 | "url": "https://www.youtube.com/watch?v=zgq4qpVOhAk", 26 | "thumbnail": "https://img.youtube.com/vi/zgq4qpVOhAk/maxresdefault.jpg", 27 | "title": "Calming Music to Overcome Sadness" 28 | }, 29 | "angry": { 30 | "url": "https://www.youtube.com/watch?v=gBfZd9fYEjw", 31 | "thumbnail": "https://img.youtube.com/vi/gBfZd9fYEjw/maxresdefault.jpg", 32 | "title": "Music to Help with Anger Management" 33 | }, 34 | "neutral": { 35 | "url": "https://www.youtube.com/watch?v=C-SPpsk7DAk", 36 | "thumbnail": "https://img.youtube.com/vi/C-SPpsk7DAk/maxresdefault.jpg", 37 | "title": "Relaxing Background Music" 38 | }, 39 | "excited": { 40 | "url": "https://www.youtube.com/watch?v=xK8hJNDvuxI", 41 | "thumbnail": "https://img.youtube.com/vi/xK8hJNDvuxI/maxresdefault.jpg", 42 | "title": "Energetic Music for Your Excitement" 43 | }, 44 | "surprised": { 45 | "url": "https://www.youtube.com/shorts/neyYOeah1jQ", 46 | "thumbnail": "https://img.youtube.com/vi/neyYOeah1jQ/maxresdefault.jpg", 47 | "title": "Interesting Videos for Surprising Moments" 48 | }, 49 | "stressed": { 50 | "url": "https://www.youtube.com/watch?v=xPnvhgVsDlE", 51 | "thumbnail": "https://img.youtube.com/vi/xPnvhgVsDlE/maxresdefault.jpg", 52 | "title": "Stress Relief Music and Meditation" 53 | }, 54 | "lonely": { 55 | "url": "https://www.youtube.com/watch?v=ZGz35cDXFqo", 56 | "thumbnail": "https://img.youtube.com/vi/ZGz35cDXFqo/maxresdefault.jpg", 57 | "title": "Music for When You Feel Alone" 58 | }, 59 | "fear": { 60 | "url": "https://www.youtube.com/watch?v=C-SPpsk7DAk", 61 | "thumbnail": "https://img.youtube.com/vi/C-SPpsk7DAk/maxresdefault.jpg", 62 | "title": "Calming Music to Overcome Fear" 63 | } 64 | } 65 | 66 | # Helper function to extract video ID from YouTube URL 67 | def get_youtube_id(url): 68 | # Regular expression to extract YouTube video ID 69 | youtube_regex = r'(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})' 70 | match = re.search(youtube_regex, url) 71 | return match.group(1) if match else None 72 | 73 | @app.route('/') 74 | def home(): 75 | if "user" in session: 76 | return redirect(url_for("chatbot")) 77 | return render_template("index.html") 78 | 79 | @app.route('/register', methods=['POST']) 80 | def register(): 81 | data = request.get_json() 82 | username = data.get("username") 83 | password = data.get("password") 84 | 85 | if username in users: 86 | return jsonify({"message": "User already exists!"}), 400 87 | 88 | users[username] = password 89 | session["user"] = username # Auto-login after registration 90 | return jsonify({"message": "User registered successfully!", "redirect": url_for("chatbot")}), 201 91 | 92 | @app.route('/login', methods=['POST']) 93 | def login(): 94 | data = request.get_json() 95 | username = data.get("username") 96 | password = data.get("password") 97 | 98 | if users.get(username) == password: 99 | session["user"] = username 100 | return jsonify({"message": "User login successful!", "redirect": url_for("chatbot")}), 200 101 | 102 | return jsonify({"message": "Invalid credentials!"}), 401 103 | 104 | # Admin Login Route 105 | @app.route('/admin', methods=['POST']) 106 | def admin_login(): 107 | data = request.get_json() 108 | username = data.get("username") 109 | password = data.get("password") 110 | 111 | if username == "admin" and password == "admin123": 112 | session["admin"] = username 113 | return jsonify({"message": "Admin login successful!", "redirect": url_for("admin_panel")}), 200 114 | 115 | return jsonify({"message": "Invalid admin credentials!"}), 401 116 | 117 | # Admin Panel Route 118 | @app.route('/admin_panel') 119 | def admin_panel(): 120 | if "admin" not in session: 121 | return redirect(url_for("home")) 122 | return render_template("admin.html") 123 | 124 | # Fetch Feedback for Admin Panel 125 | @app.route('/get-feedback', methods=['GET']) 126 | def get_feedback(): 127 | if "admin" not in session: 128 | return jsonify({"error": "Unauthorized"}), 403 129 | return jsonify(feedback_list), 200 130 | 131 | @app.route('/logout') 132 | def logout(): 133 | session.pop("user", None) 134 | session.pop("admin", None) 135 | return redirect(url_for("home")) 136 | 137 | @app.route('/chatbot') 138 | def chatbot(): 139 | if "user" not in session: 140 | return redirect(url_for("home")) 141 | return render_template("chatbot.html") 142 | 143 | @app.route('/chat', methods=['POST']) 144 | def chat(): 145 | data = request.get_json() 146 | user_message = data.get("message", "").strip().lower() 147 | 148 | greetings = { 149 | "hi": "👋 Hello! How can I assist you today?", 150 | "hello": "👋 Hello! How can I help you?", 151 | "hey": "👋 Hey! How's your day going?" 152 | } 153 | farewells = { 154 | "bye": "👋 Goodbye! Have a great day!", 155 | "bii": "👋 Goodbye! Have a great day!", 156 | "goodbye": "👋 Goodbye! Take care!", 157 | "see you": "👋 See you later!", 158 | "take care": "😊 Take care! Stay safe!" 159 | } 160 | 161 | if user_message in greetings: 162 | return jsonify({"reply": greetings[user_message]}) 163 | 164 | if user_message in farewells: 165 | return jsonify({"reply": farewells[user_message]}) 166 | 167 | keyword_emotions = { 168 | "happy": "happy", 169 | "joy": "happy", 170 | "excited": "excited", 171 | "sad": "sad", 172 | "depressed": "sad", 173 | "angry": "angry", 174 | "mad": "angry", 175 | "furious": "angry", 176 | "calm": "neutral", 177 | "okay": "neutral", 178 | "fine": "neutral", 179 | "good": "neutral", 180 | "stressed": "stressed", 181 | "anxious": "stressed", 182 | "lonely": "lonely", 183 | "alone": "lonely", 184 | "shocked": "surprised", 185 | "surprised": "surprised", 186 | "fear": "scared", 187 | "scared": "scared" 188 | } 189 | 190 | emotion = None 191 | for word, detected_emotion in keyword_emotions.items(): 192 | if word in user_message: 193 | emotion = detected_emotion 194 | break 195 | 196 | if emotion: 197 | video_data = VIDEO_RECOMMENDATIONS.get(emotion, VIDEO_RECOMMENDATIONS["neutral"]) 198 | bot_response = f"""Feeling {emotion}? I have a video suggestion for you:""" 199 | return jsonify({ 200 | "reply": bot_response, 201 | "showVideos": True, 202 | "videoSuggestions": [video_data] 203 | }) 204 | else: 205 | # Get 3 random video suggestions 206 | import random 207 | emotions = list(VIDEO_RECOMMENDATIONS.keys()) 208 | suggested_emotions = random.sample(emotions, min(3, len(emotions))) 209 | video_suggestions = [VIDEO_RECOMMENDATIONS[emotion] for emotion in suggested_emotions] 210 | 211 | bot_response = f"""I'm not sure how you're feeling, but here are some videos that might help:""" 212 | return jsonify({ 213 | "reply": bot_response, 214 | "showVideos": True, 215 | "videoSuggestions": video_suggestions 216 | }) 217 | 218 | @app.route("/emotion", methods=["POST"]) 219 | def emotion_response(): 220 | data = request.json 221 | emotion = data.get("emotion", "").lower() 222 | 223 | video_data = VIDEO_RECOMMENDATIONS.get(emotion, VIDEO_RECOMMENDATIONS["neutral"]) 224 | 225 | response_text = f"""I understand you're feeling {emotion}. Here's something to help you:""" 226 | 227 | return jsonify({ 228 | "reply": response_text, 229 | "showVideos": True, 230 | "videoSuggestions": [video_data] 231 | }) 232 | 233 | # Save Feedback 234 | @app.route('/feedback', methods=['POST']) 235 | def feedback(): 236 | data = request.get_json() 237 | username = session.get("user", "Guest") # Default to Guest if not logged in 238 | feedback_message = data.get("message") 239 | 240 | if feedback_message: 241 | current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") 242 | feedback_list.append({"username": username, "message": feedback_message, "date": current_date}) 243 | return jsonify({"message": "Thank you for your feedback!"}), 200 244 | return jsonify({"message": "Feedback cannot be empty!"}), 400 245 | 246 | if __name__ == "__main__": 247 | app.run(debug=True) -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | recipe: default.v1 2 | 3 | assistant_id: 20250312-203506-chewy-crocodile 4 | 5 | language: en 6 | 7 | pipeline: 8 | - name: WhitespaceTokenizer 9 | - name: RegexFeaturizer 10 | - name: LexicalSyntacticFeaturizer 11 | - name: CountVectorsFeaturizer 12 | - name: CountVectorsFeaturizer 13 | analyzer: char_wb 14 | min_ngram: 1 15 | max_ngram: 4 16 | - name: DIETClassifier 17 | epochs: 150 # Increase training iterations for better accuracy 18 | constrain_similarities: true 19 | 20 | - name: EntitySynonymMapper 21 | - name: ResponseSelector 22 | epochs: 100 23 | constrain_similarities: true 24 | - name: FallbackClassifier 25 | threshold: 0.25 # Reduce fallback sensitivity slightly 26 | ambiguity_threshold: 0.05 # Lower ambiguity sensitivity 27 | 28 | 29 | policies: 30 | - name: MemoizationPolicy 31 | - name: RulePolicy 32 | - name: UnexpecTEDIntentPolicy 33 | max_history: 5 34 | epochs: 100 35 | - name: TEDPolicy 36 | max_history: 5 37 | epochs: 100 38 | constrain_similarities: true 39 | -------------------------------------------------------------------------------- /credentials.yml: -------------------------------------------------------------------------------- 1 | # This file contains the credentials for the voice & chat platforms 2 | # which your bot is using. 3 | # https://rasa.com/docs/rasa/messaging-and-voice-channels 4 | 5 | rest: 6 | # # you don't need to provide anything here - this channel doesn't 7 | # # require any credentials 8 | 9 | 10 | #facebook: 11 | # verify: "" 12 | # secret: "" 13 | # page-access-token: "" 14 | 15 | #slack: 16 | # slack_token: "" 17 | # slack_channel: "" 18 | # slack_signing_secret: "" 19 | 20 | #socketio: 21 | # user_message_evt: 22 | # bot_message_evt: 23 | # session_persistence: 24 | 25 | #mattermost: 26 | # url: "https:///api/v4" 27 | # token: "" 28 | # webhook_url: "" 29 | 30 | # This entry is needed if you are using Rasa Enterprise. The entry represents credentials 31 | # for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers. 32 | rasa: 33 | url: "http://localhost:5002/api" 34 | -------------------------------------------------------------------------------- /domain.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | intents: 4 | - express_happiness 5 | - express_sadness 6 | - express_anger 7 | - express_stress 8 | - express_surprise 9 | - express_loneliness 10 | - greet 11 | - goodbye 12 | - fallback 13 | 14 | responses: 15 | utter_greet: 16 | - text: "👋 Hello! How can I assist you today?" 17 | 18 | utter_goodbye: 19 | - text: "👋 Goodbye! Have a great day!" 20 | 21 | utter_happiness: 22 | - text: "😊 You seem really happy! Here's a video for you: [Watch this](https://www.youtube.com/watch?v=FQDa6jJpmdA)" 23 | 24 | utter_sadness: 25 | - text: "😢 I detected sadness. Hope this helps: [Watch this](https://www.youtube.com/watch?v=zgq4qpVOhAk)" 26 | 27 | utter_anger: 28 | - text: "😡 I sense some anger. Try this to calm down: [Watch this](https://www.youtube.com/watch?v=gBfZd9fYEjw)" 29 | 30 | utter_stress: 31 | - text: "😌 Feeling stressed? Try this for relaxation: [Watch this](https://www.youtube.com/watch?v=xPnvhgVsDlE)" 32 | 33 | utter_surprise: 34 | - text: "😲 Surprised? Here's something interesting: [Watch this](https://www.youtube.com/shorts/neyYOeah1jQ)" 35 | 36 | utter_loneliness: 37 | - text: "💙 Feeling lonely? This might help: [Watch this](https://www.youtube.com/watch?v=ZGz35cDXFqo)" 38 | 39 | utter_fallback: 40 | - text: "🤔 I may not know your emotion for this, but this might interest you: [Watch this](https://www.youtube.com/)" 41 | 42 | actions: 43 | - utter_greet 44 | - utter_goodbye 45 | - utter_happiness 46 | - utter_sadness 47 | - utter_anger 48 | - utter_stress 49 | - utter_surprise 50 | - utter_loneliness 51 | - utter_fallback 52 | -------------------------------------------------------------------------------- /endpoints.yml: -------------------------------------------------------------------------------- 1 | # This file contains the different endpoints your bot can use. 2 | 3 | # Server where the models are pulled from. 4 | # https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server 5 | 6 | #models: 7 | # url: http://my-server.com/models/default_core@latest 8 | # wait_time_between_pulls: 10 # [optional](default: 100) 9 | 10 | # Server which runs your custom actions. 11 | # https://rasa.com/docs/rasa/custom-actions 12 | 13 | #action_endpoint: 14 | # url: "http://localhost:5055/webhook" 15 | 16 | # Tracker store which is used to store the conversations. 17 | # By default the conversations are stored in memory. 18 | # https://rasa.com/docs/rasa/tracker-stores 19 | 20 | #tracker_store: 21 | # type: redis 22 | # url: 23 | # port: 24 | # db: 25 | # password: 26 | # use_ssl: 27 | 28 | #tracker_store: 29 | # type: mongod 30 | # url: 31 | # db: 32 | # username: 33 | # password: 34 | 35 | # Event broker which all conversation events should be streamed to. 36 | # https://rasa.com/docs/rasa/event-brokers 37 | 38 | #event_broker: 39 | # url: localhost 40 | # username: username 41 | # password: password 42 | # queue: queue 43 | -------------------------------------------------------------------------------- /rasa_bot/actions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GopikaSenthilkumar/Sentiment-Analysis/2e3baf540c949df9636ace08f34bc262bf4da284/rasa_bot/actions/__init__.py -------------------------------------------------------------------------------- /rasa_bot/actions/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GopikaSenthilkumar/Sentiment-Analysis/2e3baf540c949df9636ace08f34bc262bf4da284/rasa_bot/actions/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /rasa_bot/actions/__pycache__/actions.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GopikaSenthilkumar/Sentiment-Analysis/2e3baf540c949df9636ace08f34bc262bf4da284/rasa_bot/actions/__pycache__/actions.cpython-38.pyc -------------------------------------------------------------------------------- /rasa_bot/actions/actions.py: -------------------------------------------------------------------------------- 1 | # This files contains your custom actions which can be used to run 2 | # custom Python code. 3 | # 4 | # See this guide on how to implement these action: 5 | # https://rasa.com/docs/rasa/custom-actions 6 | 7 | 8 | # This is a simple example for a custom action which utters "Hello World!" 9 | 10 | # from typing import Any, Text, Dict, List 11 | # 12 | # from rasa_sdk import Action, Tracker 13 | # from rasa_sdk.executor import CollectingDispatcher 14 | # 15 | # 16 | # class ActionHelloWorld(Action): 17 | # 18 | # def name(self) -> Text: 19 | # return "action_hello_world" 20 | # 21 | # def run(self, dispatcher: CollectingDispatcher, 22 | # tracker: Tracker, 23 | # domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: 24 | # 25 | # dispatcher.utter_message(text="Hello World!") 26 | # 27 | # return [] 28 | -------------------------------------------------------------------------------- /rasa_bot/config.yml: -------------------------------------------------------------------------------- 1 | recipe: default.v1 2 | 3 | assistant_id: 20250312-203506-chewy-crocodile 4 | 5 | language: en 6 | 7 | pipeline: 8 | - name: WhitespaceTokenizer 9 | - name: RegexFeaturizer 10 | - name: LexicalSyntacticFeaturizer 11 | - name: CountVectorsFeaturizer 12 | - name: CountVectorsFeaturizer 13 | analyzer: char_wb 14 | min_ngram: 1 15 | max_ngram: 4 16 | - name: DIETClassifier 17 | epochs: 150 # Increase training iterations for better accuracy 18 | constrain_similarities: true 19 | 20 | - name: EntitySynonymMapper 21 | - name: ResponseSelector 22 | epochs: 100 23 | constrain_similarities: true 24 | - name: FallbackClassifier 25 | threshold: 0.25 # Reduce fallback sensitivity slightly 26 | ambiguity_threshold: 0.05 # Lower ambiguity sensitivity 27 | 28 | 29 | policies: 30 | - name: MemoizationPolicy 31 | - name: RulePolicy 32 | - name: UnexpecTEDIntentPolicy 33 | max_history: 5 34 | epochs: 100 35 | - name: TEDPolicy 36 | max_history: 5 37 | epochs: 100 38 | constrain_similarities: true 39 | -------------------------------------------------------------------------------- /rasa_bot/credentials.yml: -------------------------------------------------------------------------------- 1 | # This file contains the credentials for the voice & chat platforms 2 | # which your bot is using. 3 | # https://rasa.com/docs/rasa/messaging-and-voice-channels 4 | 5 | rest: 6 | # # you don't need to provide anything here - this channel doesn't 7 | # # require any credentials 8 | 9 | 10 | #facebook: 11 | # verify: "" 12 | # secret: "" 13 | # page-access-token: "" 14 | 15 | #slack: 16 | # slack_token: "" 17 | # slack_channel: "" 18 | # slack_signing_secret: "" 19 | 20 | #socketio: 21 | # user_message_evt: 22 | # bot_message_evt: 23 | # session_persistence: 24 | 25 | #mattermost: 26 | # url: "https:///api/v4" 27 | # token: "" 28 | # webhook_url: "" 29 | 30 | # This entry is needed if you are using Rasa Enterprise. The entry represents credentials 31 | # for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers. 32 | rasa: 33 | url: "http://localhost:5002/api" 34 | -------------------------------------------------------------------------------- /rasa_bot/data/nlu.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | nlu: 4 | - intent: express_happiness 5 | examples: | 6 | - I'm so happy today! 7 | - This is the best day ever! 8 | - Feeling awesome and joyful 😊 9 | - I'm really enjoying this moment 10 | - I feel fantastic 11 | 12 | - intent: express_sadness 13 | examples: | 14 | - I'm feeling really down 15 | - Today has been a terrible day 😞 16 | - I feel so alone 17 | - Nothing is going right 18 | - I'm crying 19 | 20 | - intent: express_anger 21 | examples: | 22 | - I'm really mad right now 😡 23 | - I can't stand this situation 24 | - So frustrated and angry 25 | - Everything is making me angry 26 | - I'm furious 27 | 28 | - intent: express_stress 29 | examples: | 30 | - I'm feeling very stressed 😩 31 | - Too much pressure on me 32 | - I feel anxious and worried 33 | - I'm overloaded with work 34 | - I just need to relax 35 | 36 | - intent: express_surprise 37 | examples: | 38 | - Wow! I didn't expect that 😲 39 | - This is unbelievable! 40 | - I'm really shocked 41 | - That was a huge surprise 42 | - Never thought this would happen! 43 | 44 | - intent: express_loneliness 45 | examples: | 46 | - I feel lonely 😞 47 | - There's no one to talk to 48 | - I'm alone all the time 49 | - I just wish I had someone to be with 50 | - Feeling very isolated 51 | 52 | - intent: greet 53 | examples: | 54 | - Hi 55 | - Hello 56 | - Hey there 57 | - Good morning 58 | - Hi there! 59 | 60 | - intent: goodbye 61 | examples: | 62 | - Bye 63 | - See you later 64 | - Goodbye 65 | - Take care 66 | - Bye-bye 67 | - Catch you later 68 | - Talk to you soon 69 | - I'm leaving now 70 | - See you next time 71 | - Alright, see you! 72 | - I'm heading out 73 | 74 | - intent: fallback 75 | examples: | 76 | - asdkjfhaskdj 77 | - wjknfwken 78 | - qwertyuiop 79 | - random text 80 | - gibberish -------------------------------------------------------------------------------- /rasa_bot/data/rules.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | rules: 4 | - rule: Respond to happiness 5 | steps: 6 | - intent: express_happiness 7 | - action: utter_happiness 8 | 9 | - rule: Respond to sadness 10 | steps: 11 | - intent: express_sadness 12 | - action: utter_sadness 13 | 14 | - rule: Respond to anger 15 | steps: 16 | - intent: express_anger 17 | - action: utter_anger 18 | 19 | - rule: Respond to stress 20 | steps: 21 | - intent: express_stress 22 | - action: utter_stress 23 | 24 | - rule: Respond to surprise 25 | steps: 26 | - intent: express_surprise 27 | - action: utter_surprise 28 | 29 | - rule: Respond to loneliness 30 | steps: 31 | - intent: express_loneliness 32 | - action: utter_loneliness 33 | 34 | - rule: Say goodbye when the user says goodbye 35 | steps: 36 | - intent: goodbye 37 | - action: utter_goodbye 38 | 39 | - rule: Respond to unrecognized input 40 | steps: 41 | - intent: fallback 42 | - action: utter_fallback 43 | -------------------------------------------------------------------------------- /rasa_bot/data/stories.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | stories: 4 | - story: happy response 5 | steps: 6 | - intent: express_happiness 7 | - action: utter_happiness 8 | 9 | - story: sad response 10 | steps: 11 | - intent: express_sadness 12 | - action: utter_sadness 13 | 14 | - story: angry response 15 | steps: 16 | - intent: express_anger 17 | - action: utter_anger 18 | 19 | - story: stress response 20 | steps: 21 | - intent: express_stress 22 | - action: utter_stress 23 | 24 | - story: surprise response 25 | steps: 26 | - intent: express_surprise 27 | - action: utter_surprise 28 | 29 | - story: loneliness response 30 | steps: 31 | - intent: express_loneliness 32 | - action: utter_loneliness 33 | -------------------------------------------------------------------------------- /rasa_bot/domain.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | intents: 4 | - express_happiness 5 | - express_sadness 6 | - express_anger 7 | - express_stress 8 | - express_surprise 9 | - express_loneliness 10 | - greet 11 | - goodbye 12 | - fallback 13 | 14 | responses: 15 | utter_greet: 16 | - text: "👋 Hello! How can I assist you today?" 17 | 18 | utter_goodbye: 19 | - text: "👋 Goodbye! Have a great day!" 20 | 21 | utter_happiness: 22 | - text: "😊 You seem really happy! Here's a video for you: [Watch this](https://www.youtube.com/watch?v=FQDa6jJpmdA)" 23 | 24 | utter_sadness: 25 | - text: "😢 I detected sadness. Hope this helps: [Watch this](https://www.youtube.com/watch?v=zgq4qpVOhAk)" 26 | 27 | utter_anger: 28 | - text: "😡 I sense some anger. Try this to calm down: [Watch this](https://www.youtube.com/watch?v=gBfZd9fYEjw)" 29 | 30 | utter_stress: 31 | - text: "😌 Feeling stressed? Try this for relaxation: [Watch this](https://www.youtube.com/watch?v=xPnvhgVsDlE)" 32 | 33 | utter_surprise: 34 | - text: "😲 Surprised? Here's something interesting: [Watch this](https://www.youtube.com/shorts/neyYOeah1jQ)" 35 | 36 | utter_loneliness: 37 | - text: "💙 Feeling lonely? This might help: [Watch this](https://www.youtube.com/watch?v=ZGz35cDXFqo)" 38 | 39 | utter_fallback: 40 | - text: "🤔 I may not know your emotion for this, but this might interest you: [Watch this](https://www.youtube.com/)" 41 | 42 | actions: 43 | - utter_greet 44 | - utter_goodbye 45 | - utter_happiness 46 | - utter_sadness 47 | - utter_anger 48 | - utter_stress 49 | - utter_surprise 50 | - utter_loneliness 51 | - utter_fallback 52 | -------------------------------------------------------------------------------- /rasa_bot/endpoints.yml: -------------------------------------------------------------------------------- 1 | # This file contains the different endpoints your bot can use. 2 | 3 | # Server where the models are pulled from. 4 | # https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server 5 | 6 | #models: 7 | # url: http://my-server.com/models/default_core@latest 8 | # wait_time_between_pulls: 10 # [optional](default: 100) 9 | 10 | # Server which runs your custom actions. 11 | # https://rasa.com/docs/rasa/custom-actions 12 | 13 | #action_endpoint: 14 | # url: "http://localhost:5055/webhook" 15 | 16 | # Tracker store which is used to store the conversations. 17 | # By default the conversations are stored in memory. 18 | # https://rasa.com/docs/rasa/tracker-stores 19 | 20 | #tracker_store: 21 | # type: redis 22 | # url: 23 | # port: 24 | # db: 25 | # password: 26 | # use_ssl: 27 | 28 | #tracker_store: 29 | # type: mongod 30 | # url: 31 | # db: 32 | # username: 33 | # password: 34 | 35 | # Event broker which all conversation events should be streamed to. 36 | # https://rasa.com/docs/rasa/event-brokers 37 | 38 | #event_broker: 39 | # url: localhost 40 | # username: username 41 | # password: password 42 | # queue: queue 43 | -------------------------------------------------------------------------------- /rasa_bot/tests/test_stories.yml: -------------------------------------------------------------------------------- 1 | #### This file contains tests to evaluate that your bot behaves as expected. 2 | #### If you want to learn more, please see the docs: https://rasa.com/docs/rasa/testing-your-assistant 3 | 4 | stories: 5 | - story: happy path 1 6 | steps: 7 | - user: | 8 | hello there! 9 | intent: greet 10 | - action: utter_greet 11 | - user: | 12 | amazing 13 | intent: mood_great 14 | - action: utter_happy 15 | 16 | - story: happy path 2 17 | steps: 18 | - user: | 19 | hello there! 20 | intent: greet 21 | - action: utter_greet 22 | - user: | 23 | amazing 24 | intent: mood_great 25 | - action: utter_happy 26 | - user: | 27 | bye-bye! 28 | intent: goodbye 29 | - action: utter_goodbye 30 | 31 | - story: sad path 1 32 | steps: 33 | - user: | 34 | hello 35 | intent: greet 36 | - action: utter_greet 37 | - user: | 38 | not good 39 | intent: mood_unhappy 40 | - action: utter_cheer_up 41 | - action: utter_did_that_help 42 | - user: | 43 | yes 44 | intent: affirm 45 | - action: utter_happy 46 | 47 | - story: sad path 2 48 | steps: 49 | - user: | 50 | hello 51 | intent: greet 52 | - action: utter_greet 53 | - user: | 54 | not good 55 | intent: mood_unhappy 56 | - action: utter_cheer_up 57 | - action: utter_did_that_help 58 | - user: | 59 | not really 60 | intent: deny 61 | - action: utter_goodbye 62 | 63 | - story: sad path 3 64 | steps: 65 | - user: | 66 | hi 67 | intent: greet 68 | - action: utter_greet 69 | - user: | 70 | very terrible 71 | intent: mood_unhappy 72 | - action: utter_cheer_up 73 | - action: utter_did_that_help 74 | - user: | 75 | no 76 | intent: deny 77 | - action: utter_goodbye 78 | 79 | - story: say goodbye 80 | steps: 81 | - user: | 82 | bye-bye! 83 | intent: goodbye 84 | - action: utter_goodbye 85 | 86 | - story: bot challenge 87 | steps: 88 | - user: | 89 | are you a bot? 90 | intent: bot_challenge 91 | - action: utter_iamabot 92 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==2.0.1 2 | textblob==0.15.3 3 | requests==2.26.0 4 | python-dotenv==0.19.0 5 | flask-cors==3.0.10 6 | werkzeug==2.0.1 7 | Jinja2==3.0.1 8 | nltk==3.6.2 9 | numpy==1.21.2 10 | gunicorn==20.1.0 -------------------------------------------------------------------------------- /templates/admin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Admin Panel - Feedbacks 7 | 64 | 65 | 66 |
67 |

Admin Panel - User Feedback

68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
UsernameFeedbackSubmitted On
80 | 81 |
82 | 83 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /templates/chatbot.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Chatbot 7 | 8 | 221 | 222 | 223 | 224 |
225 |

Sentiment-Based Mental Health Companion

226 | 227 |

How are you feeling today?

228 |
229 | 😊 230 | 😢 231 | 😡 232 | 😐 233 | 🤩 234 | 😲 235 | 😖 236 | 🥺 237 | 😨 238 |
239 | 240 |
241 | 242 | 243 | 244 | 245 |

Provide Feedback

246 | 247 | 248 | 249 |

250 | Logout 251 |
252 | 253 | 365 | 366 | 367 | 368 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Mental Health Companion | Login 7 | 8 | 298 | 299 | 300 |
301 |
302 |
303 |
304 |

Mental Health Companion

305 |

Your personal wellness assistant for managing stress, anxiety, and improving your mental health.

306 |
307 | 308 |
309 |
310 | 311 | 312 | 313 |
314 | 315 | 316 |
317 |

Welcome Back!

318 | 319 |
320 | 321 | 322 |
323 | 324 |
325 | 326 | 327 | 328 |
329 | 330 |

331 | 332 | 333 | 334 | 337 |
338 | 339 | 340 |
341 |

Create Account

342 | 343 |
344 | 345 | 346 |
347 | 348 |
349 | 350 | 351 | 352 |
353 | 354 |

355 | 356 | 357 | 358 | 361 |
362 | 363 | 364 |
365 |

Admin Access

366 | 367 |
368 | 369 | 370 |
371 | 372 |
373 | 374 | 375 | 376 |
377 | 378 |

379 | 380 | 381 |
382 |
383 |
384 | 385 | 530 | 531 | 532 | --------------------------------------------------------------------------------