DEV Community

Anil Kumar
Anil Kumar

Posted on

Designing an Emotion-Aware Chat Backend: Patterns from Building Mendle

Most chat products treat every message as a standalone prompt. For an emotional wellness product, that's the wrong unit. The same sentence means different things depending on mood, history and who else is in the room.

This post walks through the design problems we worked through while building Mendle, an AI emotional wellness platform for individuals, teams and communities. It is written at the pattern level.

  1. Detect emotion, intent and context separately

Emotion alone isn't enough. "I'm fine" after a long silence and "I'm fine" in a cheerful thread are different inputs. We treated three signals as separate:

Emotion (what the person seems to feel)
Intent (what they want from this message: vent, ask, plan)
Context (recent conversation and longer-term mood history)

Keeping them separate makes each one testable. The platform reports 90% emotion detection accuracy, which is the number that tells you the first layer is working before you tune anything downstream.

  1. Let tone adapt, not just content

Once you have an emotion estimate, the generation layer can change its register: shorter and calmer for distress, more exploratory for curiosity. The risk is overfitting to the label. We'd recommend keeping tone adaptation soft, so a wrong classification degrades the reply slightly instead of derailing it.

  1. Build memory as a product feature

The Emotional Memory Engine (EME) turns conversations into patterns: mood shifts, engagement trends and recurring themes. This does two jobs. It personalizes the wellness journey, and it gives users insight into their own patterns. Treat stored emotional data as sensitive by default. That drives most of the privacy decisions below.

  1. Group chat needs its own signal

Individual sentiment doesn't roll up cleanly into group health. We added community-level sentiment analysis so moderators and administrators can see trends and potential concerns early. The platform reports real-time risk detection and 70% higher group engagement.

  1. Privacy is architecture, not a settings page

For sensitive emotional data, we designed around encryption, access controls and a compliance-ready structure from the start. Retrofitting these later usually means migrating data you've already collected.

  1. Latency is part of the experience

The reported 60% faster AI response time matters more here than in a typical chatbot, because a delayed reply in an emotional moment reads as indifference.

Trade-offs worth naming
More memory means more sensitive data to protect.
Emotion labels are probabilistic. Never present them to users as facts about their feelings.
Group analytics must be aggregated carefully so individuals aren't exposed.

The product screens and full service breakdown are in the Mendle case study. If you're building something similar, we also publish on AI integration services.

Top comments (0)