# Example Usage of Data

#### <mark style="color:red;">The below strategies used to take hundreds of hours, interviews, developers and costs. We provide it all with a simple API and offer the possibilities below to grow Revenue, Retention and Conversion and beat your competitors</mark>

#### Onairos Integration: Practical Examples

These examples demonstrate how to leverage sentiment and trait data to enhance personalization and functionality.

***

**1. Example: Using Onairos Data for Matching**

<figure><img src="https://1793222555-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCIECLdy0c6Hn11yWwBnI%2Fuploads%2FV9pjVvfM2G6fCSh5AAc7%2Fimage.png?alt=media&#x26;token=e026dd1f-5806-4663-a68e-a4ea8a107a83" alt=""><figcaption><p>Matching based on Traits or Qualities (which you define)</p></figcaption></figure>

In a dating or social networking app, you can use Onairos' `Traits JSON` and `Sentiment JSON` data to create highly personalized matches. Here’s an example of matching based on positive personality traits and compatible characteristics.

```javascript
  // Sample function for matching 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]; // Return the best match
}

function getCompatibilityScore(userTraits, matchTraits) {
  let score = 0;
  for (let trait in userTraits.positive_traits) {
    // Increase score if match has similar strong positive traits
    if (matchTraits.positive_traits[trait] >= 8) {
      score += matchTraits.positive_traits[trait];
    }
  }
  return score;
}

// Sample usage
const userTraits = { positive_traits: { trait1: 9.5, trait2: 8.7, trait3: 9.0 } };
const potentialMatches = [
  { id: 1, traits: { positive_traits: { trait1: 8.8, trait2: 9.0, trait3: 9.1 } } },
  { id: 2, traits: { positive_traits: { trait1: 7.5, trait2: 8.9, trait3: 8.2 } } }
];

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

In this example:

* We score each potential match based on how closely their strong traits align with the user's traits.
* This approach allows the app to recommend matches with compatible personalities.

***

**2. Example: Using Onairos Data in LLM Personalization**

<figure><img src="https://1793222555-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCIECLdy0c6Hn11yWwBnI%2Fuploads%2FzwL1IetAzCTLoOIpNAOL%2Fimage.png?alt=media&#x26;token=783c1446-d212-425b-b414-db4f92a8a1de" alt=""><figcaption><p>Onairos response data can act as CRUCIAL user context/memory</p></figcaption></figure>

Incorporate Onairos' personality data into a language model to adjust responses based on the user’s characteristics. This example shows how to modify a prompt with user personality traits to provide a tailored response.

```javascript
// Function to personalize LLM prompt based on 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 with base prompt
const userTraits = {
  positive_traits: { trait1: 9.2, trait2: 8.5, trait3: 9.8 },
  traits_to_improve: { trait1: 2.1, trait2: 3.4 }
};
const basePrompt = "Suggest an ideal vacation plan based on the user's preferences.";

const personalizedPrompt = personalizeLLMPrompt(userTraits, basePrompt);
console.log("Personalized LLM Prompt:", personalizedPrompt);

// Sample output for LLM prompt:
// "User Personality Traits: trait1: 9.2, trait2: 8.5, trait3: 9.8. Suggest an ideal vacation plan based on the user's preferences."
```

In this example:

* The `personalizeLLMPrompt` function appends a description of the user’s personality traits to the LLM prompt.
* This allows the LLM to generate responses tailored to the user’s personality.

***

**3. Example: Using Sentiment Data in Content Recommendation**

<figure><img src="https://1793222555-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCIECLdy0c6Hn11yWwBnI%2Fuploads%2F5GYSRWhXX2H6TbsKWU0C%2Fimage.png?alt=media&#x26;token=8bb5ab99-4160-40f2-99e2-7cb4ca331ee4" alt="" width="375"><figcaption><p>Improve current recommendations based on <br>what your users have viewed throughout their <br>WHOLE internet history </p></figcaption></figure>

Leverage Onairos’ `Sentiment JSON` output to recommend content that aligns with the user's current sentiment. High sentiment scores suggest positivity, which could be used to recommend uplifting content.

```javascript
javascriptCopy code// Function to filter content recommendations based on user sentiment score
function recommendContent(sentimentData, contentList) {
  const positiveContent = contentList.filter(content => content.type === "positive");
  const neutralContent = contentList.filter(content => content.type === "neutral");
  
  const averageSentiment = sentimentData.output
    .flat()
    .reduce((sum, score) => sum + score, 0) / sentimentData.output.length;
  
  return averageSentiment > 0.5 ? positiveContent : neutralContent;
}

// Sample sentiment data and content list
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 recommendedContent = recommendContent(sentimentData, contentList);
console.log("Recommended Content:", recommendedContent);
```

In this example:

* `recommendContent` selects either positive or neutral content based on the user’s sentiment scores.
* Users with high sentiment scores receive uplifting content, enhancing user experience through personalization.

***

**4. Example: Personalized Messaging Based on Traits and Sentiments**

<figure><img src="https://1793222555-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCIECLdy0c6Hn11yWwBnI%2Fuploads%2F7qggYWDblRuYLC6hTt7s%2Fimage.png?alt=media&#x26;token=34fc3a6b-97a5-4dc5-9095-784f1bc6e23d" alt=""><figcaption><p>Personalized messaging for products, basic dialogue and more!</p></figcaption></figure>

Use a combination of traits and sentiment data to personalize messaging in a customer support scenario, tailoring responses to the user's personality and mood.

```javascript
javascriptCopy code// Function to customize support message
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.trait1 > 8) {
    message += " Given your strength in optimism, we're confident you'll overcome this.";
  } else if (userTraits.traits_to_improve.trait1 < 3) {
    message += " Let's work on this together!";
  }

  return message;
}

// Example usage
const userTraits = {
  positive_traits: { trait1: 9.0 },
  traits_to_improve: { trait1: 2.5 }
};
const sentimentScore = 0.4;

const supportMessage = createSupportMessage(userTraits, sentimentScore);
console.log("Support Message:", supportMessage);
```

In this example:

* `createSupportMessage` generates a message that aligns with the user’s current mood and personality traits.
* Users with low sentiment scores receive a more comforting message, while positive traits trigger encouraging language.
