Inspiration
Calma wasn't born in a boardroom; it was born in a hospital waiting room. I have a sister who battles a severe psychiatric condition, and I have navigated my own struggles with mental health. We know the terrifying gap between "I'm not okay" and "Help is arriving."
In those moments of acute crisis—panic attacks, dissociation, or dark thoughts—the current healthcare system is too slow, and friends aren't always awake. We realized that while we have supercomputers in our pockets, we were still alone in the dark.
We asked ourselves: What if your phone wasn't just a device, but an anchor? What if AI could be trained not just to chat, but to perform psychological first aid? We built Calma because it is the application we needed to exist. It is our love letter to anyone fighting a silent battle.
What it does
Calma is a comprehensive safety net designed to catch you before you fall. It operates on three levels:
The SOS Voice Agent (The "Anchor"): This isn't a chatbot. It's a hyper-responsive voice intelligence powered by Gemini Live. When you press the SOS button, Calma speaks first. It guides you through a clinically-backed 6-Phase Intervention Protocol:
- Physiological Regulation: Guided breathing to lower heart rate.
- Sensory Grounding: Techniques to reconnect with physical reality.
- Cognitive Disruption: "Weird" questions (e.g., "Spell your name backwards") to force the prefrontal cortex to take over from the amygdala.
- Emotional Anchoring: It plays pre-recorded audio messages from your loved ones exactly when you need them most.
Intelligent Care Management: Depression often steals your memory. Calma manages your medication schedule not with annoying alarms, but with gentle, caring reminders. It tracks adherence and mood, creating a data trail that helps you and your doctor understand your patterns.
Autonomous Emergency Protocol (MCP & Tools): This is our most advanced feature. If the AI detects—through semantic analysis and tone—that the user is in imminent danger or unresponsive, it triggers a Model Context Protocol (MCP) tool call. This autonomously executes a cloud function to send SMS alerts and location data to designated "Anchors" (family members), ensuring help is summoned even if the user cannot unlock their phone.
How we built it
We architected Calma to be "Invisible Tech"—complex under the hood, simple in the hand.
- The Brain (Gemini Multimodal Live API): We bypassed traditional text-to-speech/speech-to-text pipelines which are too slow for a crisis. We use WebSockets to stream audio directly to Google's Gemini 2.0 Flash model. This achieves sub-500ms latency, allowing the user to interrupt the AI naturally—a critical feature for someone hyperventilating.
- The Ears (Web Audio API): We implemented a custom
ScriptProcessorNodepipeline to handle raw PCM 16-bit audio buffering, ensuring crystal clear bidirectional communication. - The Safety Net (MCP & Cloud Functions): We defined custom "Tools" that the AI can invoke. When the model decides "This is an emergency," it outputs a function call that our backend executes to interface with SMS gateways (Twilio) and Firebase.
- The Heart (React & Vite): The frontend is built for speed and accessibility, with a UI designed to be calming (soft palettes, minimal cognitive load) during high-stress moments.
Challenges we ran into
- The "Silence Loop" Problem: In a crisis, silence is ambiguous. Is the user breathing? Or have they passed out? We had to engineer a "Silence Detection Loop" that intelligently nudges the user ("I'm still here, take your time") without being annoying.
- Prompt Engineering for Empathy: Getting an LLM to stop sounding like a customer service bot and start sounding like a compassionate human was a journey. We iterated through dozens of "System Prompts," refining the tone to be "maternal/fraternal," slow-paced, and strictly forbidding phrases like "Calm down" (which never works).
- Environment & Security: Managing secure API keys and environment variables across different development environments (Windows/Linux) while ensuring the WebSocket connection remained stable was a persistent headache we had to solve with robust configuration management.
Accomplishments that we're proud of
- The "Auto-Start" Feature: We engineered the WebSocket handshake so the AI initiates the conversation immediately upon connection. The user doesn't have to say "Hello"—Calma is already there saying, "I'm here with you."
- Dynamic Cognitive Distraction: We taught the AI to randomize its grounding techniques. It won't just repeat the same script; it adapts based on the user's responsiveness.
- Real-Time Latency: Achieving a conversation flow that feels indistinguishable from a phone call with a human.
What we learned
We learned that latency is empathy. In a panic attack, a 2-second delay feels like abandonment. Optimizing the tech stack was not just about performance; it was about trust. We also learned that AI can be a bridge to human connection, not a replacement—using the "Love Messages" feature proved that technology can amplify human care rather than displace it.
What's next for Calma
- Biometric Integration: Connecting with Apple Watch/Fitbit to detect heart rate spikes (tachycardia) and proactively offer the SOS session before the full-blown panic attack starts.
- Therapist Dashboard: A secure portal where clinicians can review (with consent) the frequency and intensity of crises to adjust treatment plans.
- Global Reach: Localizing the "Voice Profile" to different cultural nuances of care and comfort.
Log in or sign up for Devpost to join the conversation.