> For the complete documentation index, see [llms.txt](https://onairos.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://onairos.gitbook.io/docs/developer-guides/example-usage-of-data.md).

# 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="/files/uM735oCxTcWElI2dyOzg" 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="/files/d0f7z0bFSlkGCz6ceIdN" 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="/files/qrURFVBQxJ0IJbPS4XuO" 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="/files/sL4gJryBvD5YC3221yE7" 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://onairos.gitbook.io/docs/developer-guides/example-usage-of-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
