A WhatsApp chatbot that serves as a mental health coach, built using Azure OpenAI and Twilio's WhatsApp API. This AI-powered chatbot provides mental health support, coping strategies based on Cognitive Behavioral Therapy (CBT), and mood tracking.
- Mental Health Support: Provides compassionate, evidence-based mental health guidance and support
- CBT-Based Therapy: Uses Cognitive Behavioral Therapy principles to help identify and reframe negative thought patterns
- Mood Tracking: Tracks user mood over time and provides insights on patterns
- Daily Coping Exercises: Suggests actionable exercises for managing stress, anxiety, and other challenges
- Positive Affirmations: Delivers personalized positive affirmations to boost mental well-being
- Twilio WhatsApp API Integration: Reliable WhatsApp communication through Twilio's platform
- Azure OpenAI Integration: Powered by Azure OpenAI for natural, empathetic conversations
- Conversation Memory: Maintains conversation context for more helpful responses
- Command System: Useful commands for accessing features like mood history
- Premium User Support: Enhanced features for premium subscribers
- Azure account with OpenAI access
- Azure subscription with at least $200 monthly credits
- Twilio account with WhatsApp API access
- Node.js environment (v14 or higher)
This chatbot includes built-in support for the following monetization strategies:
-
Freemium Model:
- Basic version: Free access to mental health conversations and basic coping exercises
- Premium version: Extended conversation history, detailed mood tracking, and advanced features
-
Corporate Wellness Packages:
- API for managing multiple users
- Admin dashboard for employee wellness tracking (requires additional implementation)
- Bulk user management for corporate clients
-
Professional Therapist Referrals:
- Integration points available for referring users to professional therapy
- Can be configured to connect with real therapists through a partnership program
- Clone this repository
- Install dependencies:
npm install
- Copy
.env.example
to.env
and update with your Azure OpenAI and Twilio credentials - Start the application:
npm start
- Set up a Twilio webhook pointing to your application's
/api/whatsapp/incoming
endpoint - Test your bot by sending a message to your Twilio WhatsApp number
- Sign up for a Twilio account at https://www.twilio.com
- Activate the Twilio Sandbox for WhatsApp in your Twilio console
- Add your Twilio account SID, auth token, and WhatsApp number to your
.env
file - Configure the webhook URL in Twilio to point to your application's
/api/whatsapp/incoming
endpoint - Follow Twilio's instructions to connect your WhatsApp number to the sandbox
Users can interact with the chatbot using the following commands:
/help
- Show all available commands/mood
- View mood history and trends/exercise
- Get a random coping exercise/affirmation
- Receive a positive affirmation/upgrade
- Learn about premium features/clear
- Clear conversation history
Users can also track their mood by sending messages like "My mood is 7/10" or request specific help with phrases like "I need help with anxiety" or "Give me a coping exercise for stress."
The chatbot implements Cognitive Behavioral Therapy principles:
- Identifying Negative Thoughts: Helps users recognize unhelpful thinking patterns
- Challenging Distortions: Guides users to question and reframe irrational thoughts
- Behavioral Activation: Encourages small positive actions to improve mood
- Coping Strategies: Provides evidence-based techniques for managing difficult emotions
- Positive Reinforcement: Acknowledges and encourages progress
For detailed deployment instructions, see DEPLOYMENT.md.
- All conversations are private and secure
- Data is stored in memory by default (production deployments should use a database)
- No personal information is shared with third parties
- Users can clear their conversation history at any time
MIT