Emotion API

The Emotion API allows you to access and utilize emotional data from Inworld AI characters. This API provides information about the emotional state of characters during interactions, enabling more nuanced and realistic character behaviors in your applications.

Overview

The Emotion API returns an emotion object with every character response. This object contains information about the character's current emotional state, including:

Emotion Object Structure

{
  "emotion": {
    "primary": "joy",
    "intensity": 0.7,
    "secondary": ["interest", "excitement"],
    "trajectory": "increasing"
  }
}

Primary Emotions

The primary emotion represents the dominant emotional state of the character. Possible values include:

Emotion Intensity

The intensity value ranges from 0.0 to 1.0, representing the strength of the primary emotion:

Secondary Emotions

Secondary emotions provide additional context to the character's emotional state. These are represented as an array of emotion labels.

Emotional Trajectory (New Feature)

The emotional trajectory indicates how the character's emotion is changing over time. Possible values are:

Using the Emotion API

To access emotional data in your application, you can use the following code snippet:

inworldClient.sendText('Hello, how are you feeling today?').then((response) => {
  console.log('Character response:', response.text);
  console.log('Emotional state:', response.emotion);
  
  // Use the emotional data to influence character behavior or appearance
  updateCharacterMood(response.emotion);
});

Best Practices

Note: The Emotion API is continuously being improved. Check the changelog for the latest updates and new features.

Related Resources