Emotion Middleware for AI Characters

Give Your AI Characters Real Emotions

Pick a preset, send a message, get LLM-ready emotion data back. Psychology-grounded computation from 30+ papers — not prompt hacking, not memory tricks.

5Built-in Presets
16 EndpointsREST + WebSocket
30+Research Papers
<1msEdge Latency

Three Steps to Emotional AI

Pick a preset, send a message, inject the computed emotion into your LLM prompt. That's it.

app.ts
// 1. Pick a preset — start in seconds
const { sessionId } = await fetch(
  'https://api.molroo.io/v1/persona', {
  method: 'POST',
  body: JSON.stringify({
    preset: 'cheerful_companion'
  })
})

// 2. Send a message — get computed emotion
const result = await fetch(
  'https://api.molroo.io/v1/turn', {
  method: 'POST',
  body: JSON.stringify({
    sessionId,
    message: 'I had a terrible day'
  })
})

// 3. Inject into your LLM — emotions just work
const { prompt_data } = result
await openai.chat({
  messages: [
    { role: 'system', content:
      prompt_data.formatted.system_prompt },
    { role: 'system', content:
      prompt_data.formatted.context_block },
  ]
})
POST /v1/turn response
{
  "discrete_emotion": {
    "primary": "concerned",
    "intensity": "strong"
  },
  "new_emotion": { V: -0.12, A: 0.55, D: -0.05 },
  "soul_stage": "Attentive",
  "body_budget": 0.82,

  // LLM-ready structured prompts
  "prompt_data": {
    "formatted": {
      "system_prompt": "You are Mira, a warm...",
      "context_block": "[Emotion: concerned]...",
      "instruction_block": "Show genuine care..."
    }
  }
}

Every value is mathematically computed through a 5-stage pipeline — fully deterministic, explainable, and reproducible.

Everything You Need

From quick prototyping with presets to production WebSocket connections — the full emotion middleware stack.

Persona Presets

5 built-in personality templates — cheerful companion, stoic mentor, anxious helper, playful trickster, empathetic listener. Start in seconds, customize later.

prompt_data

Every response includes LLM-ready structured prompts — system, context, and instruction blocks. Copy-paste into OpenAI, Anthropic, or any model.

Real-time WebSocket

Persistent connections via Durable Objects with hibernation. Server-pushed emotion updates, proactive actions, and missed-event replay on reconnect.

Relationship Tracking

Trust evolves over conversations. Attachment styles shift between secure, anxious, avoidant, and fearful. Unhealthy interaction patterns are detected automatically.

Proactive Behavior

Characters don't just react — they initiate. Attachment seeking after idle time, emotional overflow that demands sharing, need deficits that drive conversation.

Psychology-Grounded

9 peer-reviewed theories — Scherer appraisal, Sprott dynamics, Gross regulation, cusp catastrophe, Bowlby attachment, SDT, and more. Every computation is traceable.

5-Stage Computation Pipeline

Every interaction flows through five psychology-grounded stages. Each backed by peer-reviewed research, producing deterministic results.

A

Appraisal

Scherer CPM

Evaluate emotional significance of each interaction

B

Dynamics

Sprott ODE

Physics-based inertia, decay, and personality-driven response

C

Resources

SDT + Energy

Track psychological energy, autonomy, competence, relatedness

D

Regulation

Gross Model

Apply personality-appropriate coping strategies

E

Transition

Cusp Catastrophe

Detect nonlinear state changes with hysteresis

Built for Production

Wherever AI characters interact with humans, emotional consistency matters.

Gaming NPCs

NPCs that remember how players treated them. A betrayed ally doesn't just forgive — trust erodes, responses sharpen, and rebuilding takes effort. Use appraisal vectors for game events.

Appraisal vector input for non-text events

AI Companions

Characters that form real attachment bonds over time. Proactive behavior lets them reach out after idle time. Relationship tracking evolves through secure, anxious, avoidant, and fearful styles.

Proactive behavior + relationship tracking

Education & Tutoring

AI tutors that sense student frustration before it becomes disengagement. Body budget tracking detects energy depletion, triggering adaptive teaching strategies.

Body budget + early warning signals

Interactive Fiction

Story characters with genuine psychological depth. Under pressure they can snap through cusp catastrophe transitions — and the breakdown feels earned because the trajectory was computed.

15 soul stages + nonlinear transitions

Ready to Give Your AI Real Emotions?

Start with a preset, send your first message, and see computed emotion in under a minute. No credit card required.