Documentation

Context-Based Emotion API

Analyze emotions with full conversation context for more accurate detection and understanding of emotional progression.

Overview

This API analyzes emotions while considering the full conversation history, providing deeper insights into how emotions evolve and interact throughout a dialogue.

  • • Tracks emotional progression over time
  • • Understands context from previous messages
  • • Detects emotional shifts and triggers
  • • Provides conversation-level insights
POST/v1/emotion/analyze

Analyze emotions with full conversation context.

Parameters

messagesarrayRequired

Array of conversation messages for context

userIdstring

User identifier for tracking emotional patterns

sessionIdstring

Session identifier for conversation continuity

Example

Requestbash
curl -X POST "https://api.kaiko.ai/v1/emotion/analyze" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "I have been waiting for 2 hours",
        "timestamp": "2024-01-15T10:00:00Z"
      },
      {
        "role": "assistant",
        "content": "I apologize for the wait. Let me check on that.",
        "timestamp": "2024-01-15T10:01:00Z"
      },
      {
        "role": "user",
        "content": "This is completely unacceptable!",
        "timestamp": "2024-01-15T10:15:00Z"
      }
    ],
    "userId": "user_123",
    "sessionId": "session_456"
  }'
Responsejson
{
  "analysis": {
    "currentEmotion": {
      "primary": "anger",
      "intensity": 0.89,
      "secondary": ["frustration", "disappointment"]
    },
    "emotionalProgression": [
      {
        "timestamp": "2024-01-15T10:00:00Z",
        "emotion": "impatience",
        "intensity": 0.65
      },
      {
        "timestamp": "2024-01-15T10:15:00Z",
        "emotion": "anger",
        "intensity": 0.89
      }
    ],
    "triggers": [
      "extended wait time",
      "lack of resolution"
    ],
    "recommendations": [
      "Immediate escalation recommended",
      "Offer concrete solution or compensation",
      "Acknowledge frustration explicitly"
    ]
  },
  "sentiment": {
    "score": -0.85,
    "label": "very negative",
    "trend": "worsening"
  }
}