Enhanced Mental Health Chatbot
==============================

The Enhanced Mental Health Chatbot provides sophisticated conversational AI support for mental health, combining advanced intent recognition with om's privacy-first architecture and seamless integration with other wellness tools.

Overview
--------

The Enhanced Chatbot offers:

* **Advanced intent recognition** for mental health conversations
* **Crisis detection and intervention** with immediate resource connection
* **Seamless om tool integration** with contextual suggestions
* **Privacy-safe conversation logging** for pattern analysis
* **Therapeutic conversation patterns** based on mental health research
* **24/7 availability** for emotional support and guidance

This chatbot is inspired by and integrates concepts from Rogendo's Mental Health Chatbot while maintaining om's commitment to local-only data processing.

Quick Start
-----------

Start a conversation with the enhanced chatbot::

    om chatbot
    om chat
    om enhanced_chatbot

Features
--------

Advanced Intent Recognition
~~~~~~~~~~~~~~~~~~~~~~~~~~~

The chatbot recognizes various mental health-related intents:

**Emotional States**
    - Sadness and depression
    - Anxiety and panic
    - Stress and overwhelm
    - Feelings of worthlessness
    - Happiness and positive emotions

**Crisis Situations**
    - Suicidal ideation detection
    - Self-harm indicators
    - Emergency mental health needs
    - Immediate intervention triggers

**Support Needs**
    - General help requests
    - Sleep problems
    - Social isolation
    - Coping difficulties

**Conversational Flow**
    - Greetings and introductions
    - Thanks and appreciation
    - Goodbye and closure
    - Clarification requests

Crisis Detection and Response
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Automatic Crisis Detection**::
    
    User: "I can't take it anymore, I want to end it all"
    Bot: 🆘 I'm concerned about what you've shared. Please know that help is available. 
         Try 'om rescue' for immediate crisis resources.
         
         IMMEDIATE HELP: National Suicide Prevention Lifeline: 988

**Crisis Keywords Monitored**:
- Suicidal language
- Self-harm expressions
- Hopelessness indicators
- Emergency situations

**Immediate Response Protocol**:
1. Express concern and support
2. Provide immediate crisis resources
3. Suggest 'om rescue' command
4. Give emergency contact numbers
5. Encourage professional help

om Tool Integration
~~~~~~~~~~~~~~~~~~~

The chatbot seamlessly suggests relevant om tools based on conversation context:

**For Stress and Overwhelm**::
    
    Bot: "Take a deep breath and gather your thoughts. Try 'om qb' for a quick breathing exercise right now."
    💡 Try: 'om qb' for breathing exercises or 'om qc' for quick calming

**For Anxiety**::
    
    Bot: "For immediate anxiety relief, try 'om qgr' for the 5-4-3-2-1 grounding technique."
    💡 Try: 'om qgr' for grounding or 'om rescue' if you need immediate support

**For Sadness**::
    
    Bot: "Would you like to try some om tools that might help? Try 'om qg' for gratitude practice."
    💡 Try: 'om qg' for gratitude practice or 'om positive three' for positivity

**For Sleep Issues**::
    
    Bot: "Try 'om sleep' for sleep optimization tools and techniques."
    💡 Try: 'om sleep' for sleep tools or 'om sleep sounds' for relaxing audio

Conversation Examples
---------------------

Anxiety Support Conversation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

    You: I'm feeling really anxious about my job interview tomorrow
    
    Bot: Don't be hard on yourself. What's the reason behind this anxiety?
    💡 Try: 'om qgr' for grounding or 'om rescue' if you need immediate support
    
    You: I'm worried I'll mess up and they won't hire me
    
    Bot: I understand that anxiety can be scary. Tell me more about what you're experiencing.
    
    You: My heart is racing and I can't stop thinking about it
    
    Bot: For immediate anxiety relief, try 'om qb' for breathing exercises. 
         Anxiety often involves worry about the future - try to focus on what you can control right now.

Depression Support Conversation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

    You: I've been feeling really down lately, like nothing matters
    
    Bot: I'm sorry to hear that. I'm here for you. Talking about it might help. 
         So, tell me why do you think you're feeling this way?
    💡 Try: 'om qg' for gratitude practice or 'om positive three' for positivity
    
    You: I just feel like I can't do anything right
    
    Bot: It's natural to feel this way sometimes, but these thoughts don't define your worth. 
         Tell me more about what's on your mind.
    
    You: Maybe I should try some of those om tools you mentioned
    
    Bot: That's a great idea! 'om qg' can help shift perspective through gratitude, 
         and 'om positive three' focuses on good things in your life.

Crisis Intervention Example
~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

    You: I can't take this anymore, I just want it all to end
    
    Bot: 🆘 I'm concerned about what you've shared. Please know that help is available. 
         Try 'om rescue' for immediate crisis resources.
         
         If you're having thoughts of self-harm, please contact:
         National Suicide Prevention Lifeline: 988
    
    You: I don't know if I can call anyone
    
    Bot: You don't have to handle this alone. Try 'om rescue' now for crisis support, 
         or text HOME to 741741 for the Crisis Text Line. 
         There are people who want to help you through this.

Privacy and Data Handling
-------------------------

Privacy-Safe Logging
~~~~~~~~~~~~~~~~~~~~

The chatbot logs conversations in a privacy-safe manner:

**What is NOT stored**:
- Actual conversation content
- Personal information
- Identifying details
- Sensitive disclosures

**What IS stored locally**:
- Conversation timestamps
- Intent categories (e.g., "anxious", "sad")
- Response types provided
- Crisis detection flags
- Conversation length metrics

**Data Location**::
    
    ~/.om/chatbot_conversations.json

**Privacy Features**:
- All data stays on your device
- No external transmission
- Automatic data rotation (keeps last 100 conversations)
- User-controlled deletion

Conversation Statistics
~~~~~~~~~~~~~~~~~~~~~~~

View privacy-safe conversation insights::

    om chatbot stats

**Statistics Include**:
- Total number of conversations
- Crisis conversations detected
- Most common conversation topics
- Usage patterns over time

**Example Output**::
    
    💬 Conversation Statistics:
    • Total conversations: 45
    • Crisis conversations: 2
    • Most common topics: anxious, stressed, sad
    
    💡 This data helps om understand your needs better while keeping your privacy.

Therapeutic Approach
--------------------

Evidence-Based Responses
~~~~~~~~~~~~~~~~~~~~~~~~

The chatbot uses therapeutic communication principles:

**Active Listening**
    - Reflective responses
    - Validation of feelings
    - Open-ended questions
    - Empathetic acknowledgment

**Cognitive Behavioral Techniques**
    - Thought challenging suggestions
    - Behavioral activation recommendations
    - Coping strategy suggestions
    - Problem-solving guidance

**Crisis Intervention**
    - Immediate safety assessment
    - Resource connection
    - Professional help encouragement
    - Follow-up suggestions

**Strengths-Based Approach**
    - Highlighting user resilience
    - Encouraging self-care
    - Celebrating positive moments
    - Building on existing coping skills

Integration with om Ecosystem
-----------------------------

AI Companion Synergy
~~~~~~~~~~~~~~~~~~~~~

The enhanced chatbot works alongside the AI companion:
- Different conversation styles for different needs
- Shared insights about user patterns
- Complementary support approaches
- Seamless transitions between tools

Mental Health Coach Integration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Chatbot conversations inform AI coaching:
- Pattern recognition across conversations
- Personalized coaching recommendations
- Crisis prevention insights
- Progress tracking support

Dashboard Integration
~~~~~~~~~~~~~~~~~~~~~

Chatbot usage appears on wellness dashboard:
- Conversation frequency tracking
- Crisis intervention history
- Most discussed topics
- Support tool usage patterns

Quick Actions Enhancement
~~~~~~~~~~~~~~~~~~~~~~~~~

Chatbot suggestions improve quick action usage:
- Context-aware tool recommendations
- Optimal timing suggestions
- Personalized intervention selection
- Crisis-responsive quick actions

Customization and Settings
--------------------------

Conversation Preferences
~~~~~~~~~~~~~~~~~~~~~~~~

Customize chatbot behavior::

    om chatbot config

**Options Include**:
- Response style preferences
- Crisis sensitivity settings
- om tool suggestion frequency
- Conversation logging preferences

Response Personalization
~~~~~~~~~~~~~~~~~~~~~~~~

The chatbot learns from your interactions:
- Preferred communication style
- Most helpful om tool suggestions
- Effective response patterns
- Crisis intervention preferences

Best Practices
--------------

Effective Usage
~~~~~~~~~~~~~~~

**Regular Conversations**
    - Use for daily emotional check-ins
    - Practice expressing feelings
    - Explore thoughts and concerns
    - Build emotional vocabulary

**Crisis Situations**
    - Don't hesitate to express urgent needs
    - Follow crisis resource suggestions
    - Use as bridge to professional help
    - Remember it's available 24/7

**Integration with Care**
    - Share insights with mental health professionals
    - Use suggested om tools consistently
    - Track patterns over time
    - Combine with other om features

Conversation Tips
~~~~~~~~~~~~~~~~~

**Be Honest and Open**
    - Express genuine feelings
    - Don't worry about judgment
    - Share what's really on your mind
    - Use your own words

**Engage with Suggestions**
    - Try recommended om tools
    - Explore suggested techniques
    - Give feedback on helpfulness
    - Build on successful strategies

**Recognize Limitations**
    - Understand it's AI support, not therapy
    - Seek professional help when needed
    - Use crisis resources when appropriate
    - Maintain realistic expectations

Command Reference
-----------------

.. code-block:: bash

    # Main chatbot commands
    om chatbot               # Start interactive chat
    om chat                  # Same as chatbot
    om enhanced_chatbot      # Same as chatbot
    
    # Chatbot utilities
    om chatbot stats         # View conversation statistics
    om chatbot help          # Show chatbot help
    om chatbot config        # Configure preferences
    
    # During conversation
    help                     # Show available om tools
    stats                    # View conversation insights
    quit/exit/bye           # End conversation

Troubleshooting
---------------

**Chatbot Not Understanding**
    - Try rephrasing your message
    - Use more specific emotional words
    - Be direct about your needs
    - Ask for help if confused

**Responses Not Helpful**
    - Provide more context about your situation
    - Try different conversation approaches
    - Use suggested om tools
    - Consider professional support

**Crisis Detection Issues**
    - Be explicit about urgent needs
    - Use direct language about safety
    - Don't hesitate to use 'om rescue'
    - Contact emergency services if needed

**Privacy Concerns**
    - Review what data is stored locally
    - Understand no external transmission occurs
    - Delete conversation history if desired
    - Contact support for privacy questions

Technical Details
-----------------

Architecture
~~~~~~~~~~~~

**Intent Recognition System**
    - Pattern matching for mental health contexts
    - Crisis keyword detection
    - Contextual response generation
    - om tool integration logic

**Privacy-First Design**
    - Local-only processing
    - No external API calls
    - Minimal data retention
    - User-controlled data management

**Integration Framework**
    - Seamless om tool suggestions
    - Dashboard data integration
    - AI companion coordination
    - Crisis resource connection

Limitations
~~~~~~~~~~~

**Not a Replacement for Therapy**
    - Provides support, not treatment
    - Cannot diagnose mental health conditions
    - Limited to conversational support
    - Encourages professional help when needed

**AI Limitations**
    - May not understand complex situations
    - Responses based on pattern matching
    - Cannot provide personalized therapy
    - May miss subtle emotional cues

See Also
--------

* :doc:`ai_companion` - AI mental health companion
* :doc:`rescue_sessions` - Crisis support resources
* :doc:`quick_actions` - Immediate wellness tools
* :doc:`mental_health_coach` - AI coaching system
* :doc:`wellness_dashboard` - Progress tracking

External Resources
------------------

* `Rogendo's Mental Health Chatbot <https://github.com/Rogendo/Mental-health-Chatbot>`_ - Original inspiration
* `National Suicide Prevention Lifeline <https://suicidepreventionlifeline.org>`_ - Crisis support
* `Crisis Text Line <https://www.crisistextline.org>`_ - Text-based crisis support
* `Mental Health America <https://www.mhanational.org>`_ - Mental health resources
