Example Usage of Data

Practical examples showing how to leverage Onairos data for matching, personalization, and recommendations.

Updated 9 June 2026
examplesusagematchingpersonalizationllmarchetypenudgescontext-window
Business Value

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. Adding Onairos Data to Your LLM Context Window

After the user completes the Persona flow, fetch their approved traits from the Onairos API and inject that data into your LLM messages array as additional user context. This gives the model real personality and preference signals without building your own profiling pipeline.

import OpenAI from 'openai';

// Step 1: Get Persona data from the SDK callback or a manual API call
async function fetchPersonaData(result) {
  if (result.apiResponse) return result.apiResponse;

  const response = await fetch(result.apiUrl, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${result.token}`,
      'Content-Type': 'application/json',
    },
  });

  return response.json();
}

// Step 2: Turn Onairos traits into LLM-readable context
function buildUserContext(personaResponse) {
  const traits = personaResponse.traits;
  const positiveTraits = Object.entries(traits.positive_traits || {})
    .map(([name, score]) => `${name}: ${score}`)
    .join(', ');

  return [
    `User archetype: ${traits.archetype}`,
    `Strong traits: ${positiveTraits}`,
    `Summary: ${traits.user_summary}`,
    traits.nudges?.length
      ? `Personalized tips: ${traits.nudges.map((n) => n.text).join(' ')}`
      : null,
  ]
    .filter(Boolean)
    .join('\n');
}

// Step 3: Inject Onairos data into the LLM context window
async function askWithPersonaContext(result, userQuestion) {
  const personaResponse = await fetchPersonaData(result);
  const userContext = buildUserContext(personaResponse);

  const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

  const completion = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
      {
        role: 'system',
        content:
          'You are a helpful assistant. Use the following Onairos user context to personalize your answers.',
      },
      {
        role: 'user',
        content: `Additional user context from Onairos:\n${userContext}`,
      },
      {
        role: 'user',
        content: userQuestion,
      },
    ],
  });

  return completion.choices[0].message.content;
}

// Example: user just finished the Onairos consent flow
const onairosResult = {
  token: 'jwt_from_onComplete',
  apiUrl: 'https://api2.onairos.uk/...',
  apiResponse: {
    traits: {
      positive_traits: {
        'Creative Problem Solving': 92,
        'Adventure Seeking': 85,
        'Science Enthusiasm': 78,
      },
      traits_to_improve: { 'Structured Planning': 45 },
      user_summary: 'You are a curious, creative individual drawn to science and problem-solving.',
      archetype: 'Creative Explorer',
      nudges: [{ text: 'Try building a side project combining two of your interests.' }],
    },
  },
};

const answer = await askWithPersonaContext(
  onairosResult,
  'Suggest a weekend activity I would genuinely enjoy.'
);
How it works

The Onairos API response becomes an extra user-context message in your LLM call. The model sees archetype, traits, summary, and nudges before your actual prompt, so answers feel personalized from the first request.

2. 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 (scored 70-100)
function findBestMatch(userTraits, potentialMatches) {
  return potentialMatches.sort((a, b) => {
    const scoreA = getCompatibilityScore(userTraits, a.traits);
    const scoreB = getCompatibilityScore(userTraits, b.traits);
    return scoreB - scoreA;
  })[0];
}

function getCompatibilityScore(userTraits, matchTraits) {
  let score = 0;
  for (let trait in userTraits.positive_traits) {
    if (matchTraits.positive_traits[trait] >= 80) {
      score += matchTraits.positive_traits[trait];
    }
  }
  return score;
}

// Example usage
const userTraits = {
  positive_traits: { "Creative Problem Solving": 92, "Community Engagement": 85, "Science Enthusiasm": 78 }
};
const potentialMatches = [
  { id: 1, traits: { positive_traits: { "Creative Problem Solving": 88, "Community Engagement": 90, "Science Enthusiasm": 91 } } },
  { id: 2, traits: { positive_traits: { "Creative Problem Solving": 75, "Community Engagement": 89, "Science Enthusiasm": 82 } } }
];

const bestMatch = findBestMatch(userTraits, potentialMatches);
console.log("Best Match:", bestMatch);
How it works

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.

3. Using Archetype & Nudges for User Profiles

Display the user's archetype as a personality label and surface nudges as personalized tips in your app.

// Display archetype and nudges
const response = await fetchOnairosData(apiUrl, accessToken);
const traits = response.DataAnalysis.personality_traits;

// Show archetype as a profile badge
const archetypeLabel = `The ${traits.archetype}`;
console.log(archetypeLabel);
// "The Creative Explorer"

// Display personalized nudges as tips/cards
traits.nudges.forEach((nudge, i) => {
  console.log(`Tip ${i + 1}: ${nudge.text}`);
});
// "Tip 1: You're highly creative — try building a small side project combining two of your interests."
// "Tip 2: Consider dedicating time to structured planning exercises..."

// Use archetype for matching similar personality types
function findSimilarArchetypes(userArchetype, otherUsers) {
  return otherUsers.filter(u =>
    u.traits.archetype === userArchetype
  );
}

4. 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

5. 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(persona, sentimentScore) {
  const traits = persona.DataAnalysis.personality_traits;
  let message = "Thank you for reaching out!";

  if (sentimentScore < 0.5) {
    message += " We understand things might feel challenging right now.";
  }

  // Check if a trait exists and has a high score (70-100 scale)
  const optimism = traits.positive_traits["Positive Outlook"];
  if (optimism && optimism >= 80) {
    message += " Given your natural optimism, we're confident you'll overcome this.";
  }

  // Use archetype for tone
  if (traits.archetype.includes("Analyst") || traits.archetype.includes("Thinker")) {
    message += " Here's a detailed breakdown of what we're doing to resolve this.";
  }

  return message;
}

// Example
const persona = {
  DataAnalysis: {
    personality_traits: {
      positive_traits: { "Positive Outlook": 90 },
      traits_to_improve: { "Structured Planning": 45 },
      archetype: "Strategic Analyst",
      nudges: [{ text: "Try breaking large problems into smaller steps." }]
    }
  }
};
const sentimentScore = 0.4;

const message = createSupportMessage(persona, sentimentScore);
// "Thank you for reaching out! We understand things might feel challenging
//  right now. Given your natural optimism, we're confident you'll overcome this.
//  Here's a detailed breakdown of what we're doing to resolve this."
Ready to implement?

Start with the Web Integration or Mobile Integration guides. See Persona Data Model for the complete response schema reference.