Example Usage of Data
Practical examples showing how to leverage Onairos data for matching, personalization, and recommendations.
The strategies below used to take hundreds of hours, interviews, developers and costs. We provide it all with a simple API to grow Revenue, Retention and Conversion.
1. Using Onairos Data for Matching
In a dating or social networking app, use Onairos' Traits and Sentiment data to create highly personalized matches based on personality compatibility.
// Match users based on personality traits
function findBestMatch(userTraits, potentialMatches) {
return potentialMatches.sort((a, b) => {
const scoreA = getCompatibilityScore(userTraits, a.traits);
const scoreB = getCompatibilityScore(userTraits, b.traits);
return scoreB - scoreA; // Higher score = better match
})[0];
}
function getCompatibilityScore(userTraits, matchTraits) {
let score = 0;
for (let trait in userTraits.positive_traits) {
if (matchTraits.positive_traits[trait] >= 8) {
score += matchTraits.positive_traits[trait];
}
}
return score;
}
// Example usage
const userTraits = {
positive_traits: { creativity: 9.5, empathy: 8.7, curiosity: 9.0 }
};
const potentialMatches = [
{ id: 1, traits: { positive_traits: { creativity: 8.8, empathy: 9.0, curiosity: 9.1 } } },
{ id: 2, traits: { positive_traits: { creativity: 7.5, empathy: 8.9, curiosity: 8.2 } } }
];
const bestMatch = findBestMatch(userTraits, potentialMatches);
console.log("Best Match:", bestMatch);
We score each potential match based on how closely their strong traits align with the user's traits. This allows the app to recommend matches with compatible personalities.
2. Using Onairos Data in LLM Personalization
Incorporate personality data into LLM prompts to generate tailored responses based on user characteristics.
// Personalize LLM prompt with user traits
function personalizeLLMPrompt(userTraits, basePrompt) {
const personalityDescription = Object.entries(userTraits.positive_traits)
.map(([trait, score]) => trait + ': ' + score)
.join(", ");
return 'User Personality Traits: ' + personalityDescription + '. ' + basePrompt;
}
// Example usage
const userTraits = {
positive_traits: { creativity: 9.2, adventure: 8.5, curiosity: 9.8 },
traits_to_improve: { patience: 2.1, organization: 3.4 }
};
const basePrompt = "Suggest an ideal vacation plan based on the user's preferences.";
const personalizedPrompt = personalizeLLMPrompt(userTraits, basePrompt);
console.log(personalizedPrompt);
// Output: "User Personality Traits: creativity: 9.2, adventure: 8.5, curiosity: 9.8.
// Suggest an ideal vacation plan based on the user's preferences."
3. Using Sentiment Data for Content Recommendations
Leverage sentiment scores to recommend content that aligns with the user's current mood and preferences.
// Filter content based on user sentiment
function recommendContent(sentimentData, contentList) {
const positiveContent = contentList.filter(c => c.type === "positive");
const neutralContent = contentList.filter(c => c.type === "neutral");
const averageSentiment = sentimentData.output
.flat()
.reduce((sum, score) => sum + score, 0) / sentimentData.output.length;
return averageSentiment > 0.5 ? positiveContent : neutralContent;
}
// Example
const sentimentData = {
output: [[[0.8]], [[0.9]], [[0.6]], [[0.7]]]
};
const contentList = [
{ id: 1, type: "positive", title: "Uplifting Story" },
{ id: 2, type: "neutral", title: "General News" },
{ id: 3, type: "positive", title: "Motivational Tips" }
];
const recommended = recommendContent(sentimentData, contentList);
// Returns positive content for users with high sentiment scores
4. Personalized Messaging Based on Traits & Sentiment
Combine traits and sentiment data to personalize customer support messages.
// Customize support message based on user profile
function createSupportMessage(userTraits, sentimentScore) {
let message = "Thank you for reaching out!";
if (sentimentScore < 0.5) {
message += " We understand things might feel challenging right now.";
}
if (userTraits.positive_traits.optimism > 8) {
message += " Given your strength in optimism, we're confident you'll overcome this.";
} else if (userTraits.traits_to_improve.patience < 3) {
message += " Let's work on this together!";
}
return message;
}
// Example
const userTraits = {
positive_traits: { optimism: 9.0 },
traits_to_improve: { patience: 2.5 }
};
const sentimentScore = 0.4;
const message = createSupportMessage(userTraits, sentimentScore);
// "Thank you for reaching out! We understand things might feel challenging
// right now. Given your strength in optimism, we're confident you'll overcome this."
Start with the Web Integration or Mobile Integration guides.