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.
The Emotion API returns an emotion object with every character response. This object contains information about the character's current emotional state, including:
{
"emotion": {
"primary": "joy",
"intensity": 0.7,
"secondary": ["interest", "excitement"],
"trajectory": "increasing"
}
}
The primary emotion represents the dominant emotional state of the character. Possible values include:
The intensity value ranges from 0.0 to 1.0, representing the strength of the primary emotion:
Secondary emotions provide additional context to the character's emotional state. These are represented as an array of emotion labels.
The emotional trajectory indicates how the character's emotion is changing over time. Possible values are:
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);
});