Other Types
  1. All Blogs
  2. Product
  3. AI
  4. E-commerce
  5. User Experience
  6. Algolia
  7. Engineering

Personalizing product descriptions with Algolia + GPT-5

Published:

We talk a lot about relevance in the context of search results, but there’s a lot more to your app than just the search engine. Users interact with content (like your ecommerce store’s product catalog) at plenty of touchpoints beyond the search hits window. So how do we make the content the user sees elsewhere also relevant? In this article, let’s examine one touchpoint in particular: product descriptions.

Algolia already lets you personalize product rankings using user profiles, structured as JSON objects with detailed affinity scores for brands, categories, and more. But we can go so much further by personalizing product descriptions and other generic copy with these profiles! After all, if your product descriptions say the same thing to every shopper, you're missing out on a powerful layer of personalization that boosts engagement, trust, and conversion.

In this guide, we’ll show you how to:

  • Extract personalized data from Algolia’s JSON user profiles
  • Feed it into GPT-5 using OpenAI’s API
  • Dynamically rewrite product descriptions to match individual preferences

The result? Copy that adapts in real-time — highlighting Nike for sneakerheads, earthy tones for minimalists, or trail-ready features for outdoor runners. All with just a few lines of JavaScript.

Let’s dive in.

What Are Algolia Personalization Profiles?

As your users navigate around your site, you can send events describing every click and conversion to Algolia’s servers. The Personalization engine will use that data to build a user profile that/s stored as a lightweight JSON object composed of facet scores. A facet is any user-filterable attribute in your index — like brand, category, or color. In other words, they’re filters that are meaningful to users, as opposed to the filters only used for logistics. For each facet value, Algolia assigns a score between 0 and 100, indicating how strongly the user prefers that attribute. For example, a user who consistently clicks on Nike products might accumulate a high score for "brand": "Nike", while someone who filters by "Black" and browses through boots would show strong preferences for those categories as well.

The profiles look something like this:

{
  "userID": "user-1",
  "lastUpdatedAt": "2024-05-21T01:15:35Z",
  "type": "basic",
  "affinities": [
    {
      "name": "categories",
      "value": "Software",
      "indices": ["storefront"],
      "score": 18,
      "lastUpdatedAt": "2024-05-20T23:14:26.078071Z"
    },
    {
      "name": "color",
      "value": "Blue",
      "indices": ["storefront"],
      "score": 14,
      "lastUpdatedAt": "2024-05-21T01:15:08.590763Z"
    },
    {
      "name": "brand",
      "value": "Microsoft",
      "indices": ["storefront"],
      "score": 6,
      "lastUpdatedAt": "2024-05-21T01:15:35.465487Z"
    }
  ]
}

In short: it’s a user ID connected to a list of the user’s affinities.

These profiles are automatically maintained and continuously updated by Algolia — no manual tuning required. You can access them with the API and parse them quickly, which makes them ideal for dynamic prompt generation. Let’s test this out with the new OpenAI GPT-5, just released in August 2025. Now, instead of just ranking personalized results, the LLM will now personalize the language used to describe those results — tailoring product copy dynamically to the interests revealed in each user’s profile.

Turn JSON into Dynamic Product Copy Using GPT-5

Once you have a user’s profile from Algolia, you can generate tailored product copy that reflects exactly what the shopper cares about. OpenAI’s GPT series is especially powerful because it can interpret structured inputs like JSON and Markdown and use them to reshape descriptions with subtle, human-like personalization.

Think of the user profile as your creative brief. The top-scoring facets (like "brand": "Nike" or "color": "Black") tell GPT what to highlight about the profile, adjusting tone, emphasis, and word choice as it likes. Small tweaks in language like this can make a big impact on conversion, especially in ecommerce settings.

Let’s make it happen! If you’d like to see all the code together, here’s the link to the full JavaScript module.

First, let’s design the function to fetch our user profile from Algolia.

const fetchUserProfile = async (userID, ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY, ALGOLIA_REGION="eu") => {
  const fallbackUserProfile = {
    userID,
    type: "basic",
    affinities: [],
    lastUpdatedAt: new Date().toISOString(),
  };

  try {
    const response = await fetch(
      `https://ai-personalization.${ALGOLIA_REGION}.algolia.com/2/users/${encodeURIComponent(userID)}`,
      {
        headers: {
          "X-Algolia-Application-Id": ALGOLIA_APPLICATION_ID,
          "X-Algolia-API-Key": ALGOLIA_API_KEY,
        },
      }
    );

    if (!response.ok) {
      console.error(await response.text());
      return fallbackUserProfile;
    }

    return await response.json();
  } catch (error) {
    console.error(error)
    return fallbackUserProfile;
  }
};

This nifty little function just fetches everything from the API endpoint defined here. It’s not overly complex — this is just a lightly-modified snippet from the docs.

To make future steps a little easier, let’s steal a snippet from OpenAI’s docs and wrap up the LLM interaction into another little function, using the new Responses API:

import OpenAI from "openai";

const sendToGPT5 = (instructions, input, OPENAI_API_KEY) => // Returns a promise
  (new OpenAI({ apiKey: OPENAI_API_KEY })).responses.create({
    model: "gpt-5-nano",
    reasoning: { effort: "low" },
    instructions,
    input
  });

If you can’t tell, we love composable, functional JavaScript around here 😉

Next, let’s create a function to reduce the JSON down to a more condensed, meaningful format:

const convertProfileToMarkdown = ({ userID, affinities }) => [
  `Affinities for user "${userID}":`,
  ...affinities.map(affinity => 
    `- ${affinity.name}: ${affinity.value} (score: ${affinity.score})`
  )
].join("\\n");

This JavaScript function takes in the user profile and generates something like this:

Affinities for user "user-1":
- categories: Software (score: 18)
- color: Blue (score: 14)
- brand: Microsoft (score: 6)

Now we can generate our prompts:

export const personalizeCopy = async (userID, copy, credentials) => {
  const userProfile = await fetchUserProfile(userID, credentials.ALGOLIA_APPLICATION_ID, credentials.ALGOLIA_API_KEY, credentials.ALGOLIA_REGION);
  if (userProfile.affinities.length == 0) return;

  const markdownProfile = convertProfileToMarkdown(userProfile);

  const instructions = `You're a marketing copywriter personalizing ecommerce copy, such as product descriptions. Given a user's preference profile (facet scores) and a generic piece of copy, rewrite that content to emphasize what the user cares about most. Be subtle but relevant, maintaining the general tone and length of the original. Do not respond with anything other than the rewritten copy.`;
  
  const prompt = [
    markdownProfile,
    "",
    "Original copy:",
    copy,
    "",
    "Rewrite this copy based on the user's preferences."
  ].join("\\n");
  
  const response = await sendToGPT5(instructions, prompt, credentials.OPENAI_API_KEY);
  return { markdownProfile, output: response.output_text };
};

What it looks like in practice

Want to see some real output from this code? I passed in several simulated users from our flagship demo at spencerandwilliams.com and made it personalize this product description: This is a description about basic white socks. That’s a very dull, generic description. Here’s the log of the Markdown profiles of each user, followed up by the LLM’s version of the description for this user.

Affinities for user "sarajones-ecom-4":
- hierarchicalCategories.level1: Clothing, Shoes & Jewelry > Women (score: 4)
- hierarchicalCategories.level1: Beauty & Personal Care > Skin Care (score: 4)
- hierarchicalCategories.level1: Home & Kitchen > Bath (score: 4)
- hierarchicalCategories.level1: Health & Household > Household Supplies (score: 3)
- hierarchicalCategories.level2: Clothing, Shoes & Jewelry > Women > Clothing (score: 3)
- hierarchicalCategories.level2: Beauty & Personal Care > Skin Care > Face (score: 2)
- hierarchicalCategories.level2: Beauty & Personal Care > Skin Care > Body (score: 2)

Output: These basic white socks are the everyday staple for her wardrobe—soft cotton blend, breathable comfort, and a durable knit that keeps up with all-day wear, whether at home, out and about, or pairing with casual outfits.

Affinities for user "alexsapphire-ecom-4":
- hierarchicalCategories.level1: Clothing, Shoes & Jewelry > Men (score: 7)
- hierarchicalCategories.level1: Health & Household > Vitamins, Minerals & Supplements (score: 5)
- hierarchicalCategories.level2: Clothing, Shoes & Jewelry > Men > Clothing (score: 5)
- hierarchicalCategories.level1: Books > Literature & Fiction (score: 3)
- hierarchicalCategories.level1: Electronics > Computers & Accessories (score: 3)
- hierarchicalCategories.level1: Sports & Outdoors > Outdoor Recreation (score: 3)
- hierarchicalCategories.level2: Sports & Outdoors > Outdoor Recreation > Camping & Hiking (score: 2)
- hierarchicalCategories.level2: Books > Literature & Fiction > Genre Fiction (score: 1)
- hierarchicalCategories.level2: Health & Household > Vitamins, Minerals & Supplements > Herbal Supplements (score: 1)

Output: These basic white socks are a practical staple for a man’s wardrobe, offering everyday comfort and durability for work, outdoor adventures, or downtime.

Affinities for user "marklee-ecom-4":
- hierarchicalCategories.level1: Electronics > Television & Video (score: 6)
- hierarchicalCategories.level1: Tools & Home Improvement > Power & Hand Tools (score: 5)
- hierarchicalCategories.level2: Electronics > Television & Video > Televisions (score: 5)
- hierarchicalCategories.level1: Books > Science & Math (score: 4)
- hierarchicalCategories.level1: Sports & Outdoors > Exercise & Fitness (score: 4)
- hierarchicalCategories.level2: Tools & Home Improvement > Power & Hand Tools > Hand Tools (score: 3)
- hierarchicalCategories.level2: Tools & Home Improvement > Power & Hand Tools > Power Tools (score: 2)
- hierarchicalCategories.level2: Sports & Outdoors > Exercise & Fitness > Strength Training Equipment (score: 2)
- hierarchicalCategories.level2: Books > Science & Math > Mathematics (score: 2)

Output: This is a description about basic white socks crafted for everyday comfort and gym-ready performance, with breathable fabric and lasting support.

Affinities for user "johnsmith-ecom-4":
- hierarchicalCategories.level1: Home & Kitchen > Home Décor Products (score: 6)
- hierarchicalCategories.level1: Tools & Home Improvement > Lighting & Ceiling Fans (score: 5)
- hierarchicalCategories.level1: Office Products > Office Electronics (score: 5)
- hierarchicalCategories.level1: Pet Supplies > Dogs (score: 4)

Output: These basic white socks deliver everyday comfort for home, desk, and quick dog-went-out errands. Soft, breathable cotton keeps your feet cozy under desk lights and pairs effortlessly with a relaxed home décor vibe.

Affinities for user "lindagregson-ecom-4":
- hierarchicalCategories.level1: Clothing, Shoes & Jewelry > Women (score: 5)
- hierarchicalCategories.level1: Home & Kitchen > Kitchen & Dining (score: 4)
- hierarchicalCategories.level1: Home & Kitchen > Home Décor Products (score: 4)
- hierarchicalCategories.level2: Clothing, Shoes & Jewelry > Women > Clothing (score: 3)

Output: These basic white socks are a versatile staple for her wardrobe—soft, comfortable, and easy to pair with everyday outfits.

The analysis

Notice anything interesting in the output above? Even with only surface insights, the LLM crafted content that would make these customers more eager to buy. For example, it highlighted the feel of the socks to Sara Jones, who searches often for beauty and skincare products. Alex Sapphire seems to be a naturalist, so the LLM mentioned the practicality and outdoor adventures. Mark Lee might be building a home gym — the socks are perfect for that! John Smith is a dog-owning remote worker, and the description reflects that. We know the least about Linda Gregson, but at least we can tell that she shops for women’s clothing, so the description is tailored to match.

In all of these examples, the LLM identified something that could make the product more appealing to the user and highlighted it. That’s a service to the user (because they’re getting the most applicable recommendations surfaced quickly) and to the company (because we’re increasing the chance of a sale).

The more info we feed to the LLM, the more the description will accurately reflect why that product matches that user. If we can send condensed bullet points, product specs, the price, and even user-generated reviews, we’ll take our relevance to the next level.

How to iterate on this

If this has piqued your interest, maybe take a minute to think on these ideas for further enhancements:

  1. How might you build an A/B testing system to get measurable proof of the soft benefits of personalized copy?
  2. Could we incorporate comparisons with other products using RAG (perhaps through OpenAI’s Function Calling feature?) and Algolia’s search SDK?
  3. Has the user explicitly told us somehow what they’re interested in? Maybe the data they gave us when they created their account can improve the prompts.
  4. Can we use this flow to beta-test a new company voice? We could test out a snarkier or more casual tone on users that don’t have recorded personalization data.
  5. Could we generate these descriptions using one long conversation with the LLM, so that it gains a deeper understanding of the user journey as the session goes on?

From Data to Dialogue

Algolia’s personalization profiles are powerful snapshots of what matters most to each user. They’re distilled into clear, structured JSON, perfect for a revolutionary LLM like GPT-5. All that creates a more engaging shopping experience where every word reinforces the idea that this was made for me. When Algolia’s precision meets GPT-5’s creativity, products stop being just listings and start being stories — stories that end in sales.

ABOUT THE AUTHOR

Recommended

Get the AI search that shows users what they need