Hyper-Personalized Marketing: A Journey with Grok
You’ve dodged the internet’s ad barrage one too many times—pop-ups, banners, that 5-second YouTube teaser you’d trade anything to skip. How many ads hit you daily? How many feel like they get you, not some generic nobody? If you’re a brand, how often do your regulars see offers that truly spark their interest? Spoiler: not nearly enough.
Imagine ads that hook strangers in their native tongue and campaigns that captivate your loyal fans with perfect precision. Large language models like xAI’s Grok make this possible. Once, it was impractical for marketing teams to manually sift through user profiles and craft bespoke messages, too slow, too costly. Now, feed Grok the right context, and it takes over, blending nuanced language mastery with image-generation prowess to deliver hyper-personalized content across languages, formats, and tones in mere seconds.
Table of Contents
- Crafting Customers: Grok Builds Your Audience Profiles
- Hyper Personalized Prompt
- Image Generation
- Final Results
- Conclusion
Python (OpenAI)
%pip install --quiet openai python-dotenv tqdm pandas aiofiles
Text
Note: you may need to restart the kernel to use updated packages.
Crafting Customers: Grok Builds Your Audience Profiles
Every campaign needs a target. For ads, it’s new users with basic traits. For marketing, it’s your known crowd, rich with history. Typically, you’d pull from your database, but here, we'll use Grok to create synthetic sample profiles from scratch. First, we'll use the structured outputs feature to create sample customers with attributes that would aid in generating targeted marketing/ad content. Second, we’ll task Grok with fleshing out vivid, concrete personas—written snapshots that bring these profiles to life, ready to inspire hyper-personalized campaigns.
Synthetic Customer Generation
Below, we define a Pydantic model to shape sample customers with attributes typical of an e-commerce setting. Then, we harness Grok’s structured outputs feature to whip up 10 diverse profiles in one go.
Python (OpenAI)
import os
from dotenv import load_dotenv
from openai import AsyncOpenAI
load_dotenv()
GROK_2_IMAGE = "grok-2-image"
GROK_4 = "grok-4"
grok_client = AsyncOpenAI(
base_url="https://api.x.ai/v1", api_key=os.getenv("XAI_API_KEY")
)
Python (OpenAI)
from enum import Enum
from pydantic import BaseModel
class Gender(Enum):
MALE = "MALE"
FEMALE = "FEMALE"
class Item(BaseModel):
name: str
category: str
price: float
purchase_date: str
class Customer(BaseModel):
name: str
age: int
location: str
gender: Gender
language: str
purchase_history: list[Item]
interests: list[str]
search_history: dict[str, str]
preferred_device: str
persona: str | None = None
class Customers(BaseModel):
customers: list[Customer]
Python (OpenAI)
async def generate_customers(
client: AsyncOpenAI, num_customers: int = 10, model: str = GROK_3
) -> Customers:
prompt = f"""
Generate {num_customers} sample customers with the following attributes:
- age: int
- location: str
- gender: Gender
- language: str
- purchase_history: list[Item]
- interests: list[str]
- search_history: dict[str, str]
- preferred_device: str
Here are the attributes of an Item:
- name: str
- category: str
- price: float
- purchase_date: str
Each customer generated should varied and distinct from the others:
- ensure a variety of languages are represented and not just english, however try to focus on commonly spoken languages instead of niche ones.
- ensure the customers are from a variety of different countries and not just from one country
- ensure the language attribute is set to the most commonly spoken language in that country
- Have more english speaking customers than non-english speaking ones.
Please set the persona attribute to null for all customers.
"""
response = await client.beta.chat.completions.parse(
model=model,
messages=[{"role": "user", "content": prompt}],
response_format=Customers,
temperature=1.2,
)
if not response.choices[0].message.parsed:
raise ValueError("No personas generated")
return response.choices[0].message.parsed
Python (OpenAI)
customers = await generate_customers(grok_client, num_customers=10, model=GROK_3)
Python (OpenAI)
for customer in customers.customers:
print(customer.model_dump_json(indent=2))
Text
{
"name": "John Smith",
"age": 34,
"location": "New York, USA",
"gender": "MALE",
"language": "English",
"purchase_history": [
{
"name": "Laptop",
"category": "Electronics",
"price": 999.99,
"purchase_date": "2023-01-15"
},
{
"name": "Headphones",
"category": "Accessories",
"price": 89.99,
"purchase_date": "2023-02-20"
}
],
"interests": [
"Technology",
"Gaming",
"Travel"
],
"search_history": {
"recent": "laptop deals",
"past": "gaming accessories"
},
"preferred_device": "Smartphone",
"persona": null
}
{
"name": "Emma Brown",
"age": 28,
"location": "London, UK",
"gender": "FEMALE",
"language": "English",
"purchase_history": [
{
"name": "Winter Coat",
"category": "Clothing",
"price": 120.5,
"purchase_date": "2022-11-10"
},
{
"name": "Boots",
"category": "Footwear",
"price": 75.0,
"purchase_date": "2022-12-05"
}
],
"interests": [
"Fashion",
"Reading",
"Cooking"
],
"search_history": {
"recent": "winter fashion",
"past": "cooking recipes"
},
"preferred_device": "Tablet",
"persona": null
}
{
"name": "Michael Johnson",
"age": 45,
"location": "Sydney, Australia",
"gender": "MALE",
"language": "English",
"purchase_history": [
{
"name": "Surfboard",
"category": "Sports",
"price": 450.0,
"purchase_date": "2023-03-12"
},
{
"name": "Sunscreen",
"category": "Personal Care",
"price": 15.99,
"purchase_date": "2023-04-01"
}
],
"interests": [
"Surfing",
"Hiking",
"Photography"
],
"search_history": {
"recent": "beach gear",
"past": "hiking trails"
},
"preferred_device": "Laptop",
"persona": null
}
{
"name": "Sarah Davis",
"age": 31,
"location": "Toronto, Canada",
"gender": "FEMALE",
"language": "English",
"purchase_history": [
{
"name": "Bookshelf",
"category": "Furniture",
"price": 200.0,
"purchase_date": "2023-05-18"
},
{
"name": "Novels",
"category": "Books",
"price": 45.0,
"purchase_date": "2023-06-10"
}
],
"interests": [
"Literature",
"Art",
"Music"
],
"search_history": {
"recent": "book reviews",
"past": "art exhibitions"
},
"preferred_device": "Smartphone",
"persona": null
}
{
"name": "Robert Wilson",
"age": 52,
"location": "Manchester, UK",
"gender": "MALE",
"language": "English",
"purchase_history": [
{
"name": "Garden Tools",
"category": "Home Improvement",
"price": 85.5,
"purchase_date": "2022-07-22"
},
{
"name": "Lawn Mower",
"category": "Equipment",
"price": 320.0,
"purchase_date": "2022-08-15"
}
],
"interests": [
"Gardening",
"DIY Projects",
"Sports"
],
"search_history": {
"recent": "garden designs",
"past": "DIY tutorials"
},
"preferred_device": "Desktop",
"persona": null
}
{
"name": "Maria Garcia",
"age": 29,
"location": "Madrid, Spain",
"gender": "FEMALE",
"language": "Spanish",
"purchase_history": [
{
"name": "Dress",
"category": "Clothing",
"price": 65.0,
"purchase_date": "2023-02-14"
},
{
"name": "Handbag",
"category": "Accessories",
"price": 40.0,
"purchase_date": "2023-03-05"
}
],
"interests": [
"Fashion",
"Dance",
"Travel"
],
"search_history": {
"recent": "summer dresses",
"past": "dance classes"
},
"preferred_device": "Smartphone",
"persona": null
}
{
"name": "Lucas Silva",
"age": 38,
"location": "São Paulo, Brazil",
"gender": "MALE",
"language": "Portuguese",
"purchase_history": [
{
"name": "Soccer Ball",
"category": "Sports",
"price": 25.0,
"purchase_date": "2023-01-20"
},
{
"name": "Jersey",
"category": "Clothing",
"price": 50.0,
"purchase_date": "2023-02-10"
}
],
"interests": [
"Soccer",
"Music",
"Cooking"
],
"search_history": {
"recent": "soccer matches",
"past": "Brazilian recipes"
},
"preferred_device": "Tablet",
"persona": null
}
{
"name": "Anna Müller",
"age": 26,
"location": "Berlin, Germany",
"gender": "FEMALE",
"language": "German",
"purchase_history": [
{
"name": "Bicycle",
"category": "Sports",
"price": 300.0,
"purchase_date": "2022-09-05"
},
{
"name": "Helmet",
"category": "Accessories",
"price": 45.0,
"purchase_date": "2022-09-10"
}
],
"interests": [
"Cycling",
"Photography",
"Technology"
],
"search_history": {
"recent": "bike routes",
"past": "camera reviews"
},
"preferred_device": "Laptop",
"persona": null
}
{
"name": "Priya Sharma",
"age": 33,
"location": "Mumbai, India",
"gender": "FEMALE",
"language": "Hindi",
"purchase_history": [
{
"name": "Saree",
"category": "Clothing",
"price": 80.0,
"purchase_date": "2023-04-15"
},
{
"name": "Jewelry",
"category": "Accessories",
"price": 60.0,
"purchase_date": "2023-05-01"
}
],
"interests": [
"Fashion",
"Bollywood",
"Cooking"
],
"search_history": {
"recent": "saree designs",
"past": "Indian recipes"
},
"preferred_device": "Smartphone",
"persona": null
}
{
"name": "James Taylor",
"age": 40,
"location": "Los Angeles, USA",
"gender": "MALE",
"language": "English",
"purchase_history": [
{
"name": "Camera",
"category": "Electronics",
"price": 750.0,
"purchase_date": "2022-12-25"
},
{
"name": "Tripod",
"category": "Accessories",
"price": 90.0,
"purchase_date": "2023-01-05"
}
],
"interests": [
"Photography",
"Movies",
"Travel"
],
"search_history": {
"recent": "camera lenses",
"past": "movie reviews"
},
"preferred_device": "Laptop",
"persona": null
}
Persona Generation
With our synthetic customers in hand, we can enrich them with detailed personas—textual summaries that make them feel real. Using the AsyncClient, we generate personas for all 10 customers concurrently.
Python (OpenAI)
from tqdm.asyncio import tqdm_asyncio
async def generate_persona(
client: AsyncOpenAI, customer: Customer, model: str = GROK_3
) -> str:
response = await client.chat.completions.create(
model=model,
messages=[
{
"role": "user",
"content": f"Generate a rich, 1-2 sentence persona for the following customer: {customer.model_dump_json(indent=2)}. The persona should suitable such that it can be used to generate a hyper-personalized ad or marketing piece.",
}
],
)
persona = response.choices[0].message.content
if not persona:
raise ValueError("No persona generated")
return persona
async def set_personas(
client: AsyncOpenAI, customers: list[Customer]
) -> list[Customer]:
coroutines = [generate_persona(client, customer) for customer in customers]
personas = await tqdm_asyncio.gather(*coroutines, desc="Generating personas")
for customer, persona in zip(customers, personas):
customer.persona = persona
return customers
Python (OpenAI)
updated_customers = await set_personas(grok_client, customers.customers)
Text
Generating personas: 100%|██████████| 10/10 [00:02<00:00, 4.27it/s]
Python (OpenAI)
for customer in updated_customers:
print(customer.persona)
Text
John Smith, a 34-year-old tech-savvy New Yorker, is a passionate gamer and frequent traveler who relies on his smartphone to stay connected and hunt for the latest electronics deals. Always on the lookout for high-quality gadgets like laptops and headphones, he values cutting-edge technology to enhance both his gaming experiences and on-the-go lifestyle.
Emma Brown, a 28-year-old fashion enthusiast from London, UK, is a stylish and curious individual who loves staying ahead of seasonal trends, as seen in her recent purchases of a winter coat and boots, while also indulging her passions for reading and cooking. Often browsing on her tablet, she actively seeks inspiration for winter fashion and new recipes to elevate her culinary skills.
Michael Johnson is a 45-year-old adventure enthusiast from Sydney, Australia, who loves spending his weekends surfing at the beach or hiking through scenic trails, often capturing stunning landscapes with his camera. With a passion for outdoor activities, he actively seeks quality beach gear and personal care products like sunscreen to support his active lifestyle, preferring to research and shop using his laptop.
Sarah Davis, a 31-year-old creative soul from Toronto, Canada, is a passionate lover of literature, art, and music, often seeking inspiration through novels, book reviews, and local art exhibitions. With a keen eye for stylish home decor, as seen in her recent bookshelf purchase, she enjoys curating her space while staying connected on her smartphone, always on the lookout for meaningful cultural experiences.
Robert Wilson, a 52-year-old man from Manchester, UK, is a passionate gardener and DIY enthusiast who enjoys transforming his outdoor space with tools and equipment like garden tools and lawn mowers, often seeking inspiration from garden designs and tutorials on his desktop. His love for hands-on projects and sports reflects a practical, active lifestyle, making him an ideal target for personalized offers on innovative gardening solutions and home improvement gear.
Maria Garcia is a vibrant 29-year-old from Madrid, Spain, with a keen eye for fashion, often browsing for trendy summer dresses and stylish accessories on her smartphone to complement her active lifestyle filled with dance and travel. Her love for self-expression through clothing and her passion for cultural exploration make her the perfect target for personalized offers on chic, travel-friendly outfits and local dance events.
Lucas Silva, a 38-year-old passionate soccer enthusiast from São Paulo, Brazil, is a vibrant individual who loves cheering for his favorite team, cooking traditional Brazilian dishes, and enjoying music on his tablet. Always on the lookout for the latest soccer gear and local match updates, Lucas combines his zest for sports with a deep appreciation for his cultural roots.
Anna Müller, a 26-year-old Berliner, is an adventurous and tech-savvy cyclist who loves exploring new bike routes across the city while capturing stunning visuals with her camera. Her passion for cycling, evident from her recent bicycle and helmet purchases, combined with her interest in photography and technology, makes her the perfect candidate for innovative gear that enhances her active lifestyle and creative pursuits.
Priya Sharma is a 33-year-old vibrant woman from Mumbai, India, who embodies a deep love for fashion and Bollywood, often seeking the latest saree designs to express her cultural elegance. With a passion for cooking traditional Indian recipes and a preference for browsing on her smartphone, she values both style and heritage in her daily life.
James Taylor is a 40-year-old photography enthusiast from Los Angeles, USA, who is passionate about capturing life’s moments through his camera and often seeks out the latest gear, like lenses, to enhance his craft. As a frequent traveler and movie buff, he likely uses his laptop to research equipment, read movie reviews, and plan trips to inspiring destinations.
Hyper Personalized Prompt
With customers and personas ready, it’s time to craft hyper-personalized marketing messages. The prompt below instructs Grok to generate short, punchy ads tailored to each customer’s unique profile, think 50-100 words that pop with excitement, weave in at least three specific attributes (like age, interests, or purchase history), and match their language and local vernacular. These messages pitch a fresh product tied to their data, complete with a compelling hook and a clear call-to-action.
The prompt below includes a number of techniques that help get the best out of Grok these include:
- Role assignment
- A well defined task with specific criteria
- Detailed step by step instructions on how to perform the task
- Constraints to tell Grok what to avoid
- A reminder towards of the end of the prompt of the most important high-level instructions
Python (OpenAI)
async def generate_marketing_piece(
client: AsyncOpenAI, customer: Customer, model: str = GROK_3
) -> str:
prompt = f"""
You are an expert marketing content generator tasked with creating hyper-personalized, engaging, and exciting advertising content for individual customers. Your goal is to leverage detailed customer data to craft tailored messages that resonate with their demographics, behaviors, and preferences, while optionally aligning with a brand style guide where possible.
Below is the Customer schema outlining the attributes that will be provided as input:
{Customer.model_json_schema()}
Task
Given a single `Customer` instance (provided as input), generate a short, personalized marketing message (50-100 words) that:
1. Feels exciting, urgent, or exclusive to grab attention.
2. Incorporates at least 3 specific attributes from the customer's data (e.g., `age`, `purchase_history`, `interests`).
3. Matches the customer's `language` and uses idiomatic lingo based on the customer's `location`.
4. Aligns with their `preferred_device` for delivery.
5. Suggests a specific product or service (either dynamically generated or inferred from data) tied to their purchase history, interests, or search history - but not something they have recently purchased.
Instructions
1. Analyze the Customer: Use attributes like `age`, `gender`, `location`, `purchase_history`, `interests`, `search_history`, and `preferred_device` to understand the customer. If `persona` is missing, infer a simple persona (e.g., "Tech-Savvy Gamer," "Eco-Chic Shopper") based on patterns.
2. Generate a Product/Service (if not provided): If no specific product is given, create one based on the customer’s data. Example: For a customer with `interests: ["sustainability"]` and `purchase_history: ["Dress"]`, suggest a "Vegan Leather Bag" in the "Fashion" category for $45.
2. Personalized Greeting: Always address the customer by their first name in the greeting
3. Tailor the Tone: Adjust language and style to suit `age`, `gender`, and `interests`. For younger audiences, use casual, vibrant tones; for older audiences, use polished, professional tones.
4. Use the language of the customer: Use idiomatic vernacular based on the customer's `location`.
5. Use emojis: Use emojis to add a bit more flair to the message, but don't overdo it.
6. Leverage Context: Reference `location` (e.g., local events), `purchase_date` (e.g., time since last purchase), or `search_history` (e.g., intent) for relevance.
7. Create Hooks: Use storytelling ("Remember your last buy?"), exclusivity ("For our top shoppers only"), or FOMO ("This week only!") to engage.
8. Personalize Offers: Suggest the product with a compelling deal (e.g., discount, bundle) tied to `purchase_history` or `search_history`. Use plausible pricing if generating a product.
9. Optimize Delivery: Format for `preferred_device`—short and visual for "mobile," detailed for "desktop."
10. Stay Concise: Keep the message 50-100 words, punchy, and action-oriented with a clear call-to-action (CTA), using new lines for clarity and structure where necessary.
Constraints
- Do not invent customer data not present in the `Customer` instance.
- Avoid generic phrases like "Dear Customer" unless no personalization data is available.
- Use the exact `language` specified (e.g., English, Japanese) and match cultural nuances where possible.
- Do not exceed 100 words unless explicitly requested.
Remember to:
- Be creative but grounded in the data.
- If generating a product, ensure it’s plausible and tied to the customer’s profile.
- If unsure about cultural references, keep it simple and data-driven.
- Only output the final advertising content and nothing else.
Here is the customer:
{customer.model_dump_json(indent=2, exclude={"persona"})}
Here is the customer persona:
{customer.persona}
Here is the target language:
{customer.language}
"""
response = await client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
)
if not response.choices[0].message.content:
raise ValueError("No marketing piece generated")
return response.choices[0].message.content
Python (OpenAI)
marketing_pieces: list[str] = await tqdm_asyncio.gather(
*[
generate_marketing_piece(grok_client, customer)
for customer in updated_customers
]
)
Text
100%|██████████| 10/10 [00:05<00:00, 1.94it/s]
Python (OpenAI)
import pandas as pd
pd.set_option("display.max_colwidth", None)
df = pd.DataFrame(
{
"Customer JSON": [
customer.model_dump_json(indent=2) for customer in updated_customers
],
"Customer Persona": [customer.persona for customer in updated_customers],
"Marketing Piece": marketing_pieces,
}
)
df
Text
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
In just a matter of seconds we've created hyper personalized relevant marketing material, in a variety of vastly different languages, with idiomatic language. Our prompt above focuses on short punchy ads but this can easily be adjusted to fit a specific format or style to suit your needs.
Image Generation
Why stop at text? Let’s amp up these marketing pieces with eye-catching images. Using Grok’s image-generation capabilities, we’ll create visuals based on each marketing message and persona. These images spotlight the product in a stylized, engaging scene—think vibrant watercolors or bold graphics tied to the customer’s interests and lifestyle, all without humans to keep the focus tight.
Meta-Prompting
Typically, the image generation API works by taking a prompt that describes the image you want created. We could pass a prompt directly here, but instead, we use a meta-prompt, a prompt fed into a non-image-generation model to craft a tailored prompt optimized for the image gen API. This lets us get ultra-specific, ensuring the generated prompt perfectly aligns with the customer’s persona and marketing piece for standout visuals.
Note: The image generation API actually takes the prompt you give it and re-writes it anyway, which might make this step seem redundant. However, even with that re-writing process, providing a high quality and descriptive initial prompt often leads to better quality end images.
Python (OpenAI)
async def generate_image_prompt(
client: AsyncOpenAI,
marketing_piece: str,
customer_persona: str,
model: str = GROK_3,
) -> str:
meta_prompt = f"""
Create a concise and detailed prompt optimized for an image generation model based on the persona and marketing piece provided below.
The generated prompt should:
- Instruct the model to create an image promoting the product or service from the marketing piece, with the product or service as the central focus.
- Exclude humans from the image.
- Place the product or service in a visually engaging, stylized context that reflects the persona’s interests, lifestyle, or preferences.
- Include subtle background elements or details that tie into the persona’s characteristics (e.g., hobbies, environment) to enhance relevance, without distracting from the product or service.
- Use vivid, descriptive language to inspire a creative and unique visual output, keeping the tone imaginative rather than literal.
- Instruct the model to use different styles, not all photos need to be hyper-realistic but some may be more artistic, sketched, paintings, watercolor style etc. The style used should be chosen based on the marketing piece and persona.
- Format the output as a single, flowing sentence or short paragraph, avoiding lists or numbered steps, suitable for direct input into an image generation tool.
Steps to Generate the Prompt:
1. Analyze the marketing piece to pinpoint the product or service and its key selling points.
2. Examine the persona to extract specific traits, interests, or motivations that connect to the product or service.
3. Craft a scene where the product or service shines in a context meaningful to the persona, such as the city or location, blending in subtle, complementary details based on the persona's characteristics.
4. Ensure the language is evocative, visual, and concise, tailored for an image generation model’s interpretation.
Persona:
{customer_persona}
Marketing Piece:
{marketing_piece}
"""
response = await client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": meta_prompt}],
max_tokens=400,
)
if not response.choices[0].message.content:
raise ValueError("No image prompt generated")
return response.choices[0].message.content
Python (OpenAI)
import base64
import os
import uuid
import aiofiles
async def generate_image(
client: AsyncOpenAI, marketing_piece: str, customer_persona: str, filepath: str
) -> str:
image_prompt = await generate_image_prompt(
grok_client, marketing_piece, customer_persona
)
print(image_prompt)
response = await client.images.generate(
model="grok-2-image", prompt=image_prompt, response_format="b64_json"
)
if not response.data:
raise ValueError("No image generated")
b64_json = response.data[0].b64_json
if b64_json is None:
raise ValueError("No base64 data received in response")
image_data = base64.b64decode(b64_json)
filename = os.path.join(filepath, f"generated_image_{uuid.uuid4().hex[:5]}.png")
async with aiofiles.open(filename, "wb") as f:
await f.write(image_data)
return filename
Python (OpenAI)
async def generate_all_images(client: AsyncOpenAI, df: pd.DataFrame, images_dir: str):
tasks = [
generate_image(
client, row["Marketing Piece"], row["Customer Persona"], images_dir
)
for _, row in df.iterrows()
]
image_paths = await tqdm_asyncio.gather(*tasks)
df["image_path"] = image_paths
return df
Python (OpenAI)
df = await generate_all_images(grok_client, df, "generated_images/")
Text
0%| | 0/10 [00:00<?, ?it/s]
Create a stunning image showcasing a luxurious "Designer Lehenga Choli" as the centerpiece, radiating Bollywood-inspired glamour with intricate embroidery and vibrant jewel tones, elegantly draped over a polished mannequin in the heart of a dreamy Mumbai-inspired setting, where the golden hues of a sunset illuminate the bustling cityscape in the background, with subtle hints of Priya’s world—such as a vintage Bollywood poster peeking from a nearby wall and a small copper cooking pot resting on a market stall—blending seamlessly into the scene without overshadowing the outfit, all rendered in a rich, artistic watercolor style to capture the cultural elegance and emotional warmth of Priya’s vibrant lifestyle.
Create a stunning image that showcases a pair of elegant travel sandals as the centerpiece, artfully arranged on a sun-warmed cobblestone street in the heart of Madrid at golden hour, with the vibrant essence of Maria’s lively spirit infused into the scene through subtle background details like a fluttering flamenco shawl draped nearby and a glimpse of a historic Spanish plaza adorned with blooming bougainvillea, evoking her passion for dance and cultural exploration, all while maintaining a dreamy, watercolor-style aesthetic that captures the warmth and artistic flair of a summer evening in Spain, ensuring the sandals remain the focal point with their intricate design and travel-ready charm glowing under the soft, painted light.
Create a visually captivating image that showcases a premium camera lens as the central focus, gleaming with intricate details under a soft, golden-hour glow, positioned on a weathered wooden table in an artistic, sketch-like style reminiscent of a vintage movie storyboard, evoking a cinematic charm that resonates with a photography enthusiast and movie buff from Los Angeles; surround the lens with subtle background elements like a faintly sketched map of iconic LA landmarks and a few scattered, faded film reels, hinting at a passion for travel and cinema, while keeping the lens as the undeniable star of the composition, framed against a dreamy, blurred backdrop of a coastal sunset to inspire wanderlust and creativity.
Create a visually captivating image that showcases a luxurious wool-blend scarf as the centerpiece, elegantly draped over a sleek, modern coat rack in the heart of a cozy, stylish London flat, with the city’s iconic foggy skyline subtly visible through a large window in the background, hinting at Emma’s urban lifestyle; surround the scarf with faint, artistic touches like an open fashion magazine and a steaming cup of tea on a nearby table to reflect her love for reading and cooking, while the scene is rendered in a soft, watercolor style to evoke a dreamy, trendsetting vibe that matches her passion for seasonal fashion, ensuring the scarf remains the focal point amidst these delicate, complementary details.
Create a visually striking image that showcases a premium Gaming Mouse as the central focus, glowing with futuristic neon blue and red accents, perched on a sleek, angular desk setup amidst a stylized, cyberpunk-inspired New York City skyline at night, with towering skyscrapers and holographic billboards subtly reflecting John’s tech-savvy, gamer lifestyle; infuse the scene with faint traces of digital circuit patterns and gaming icons like pixelated controllers or joysticks etched into the background, ensuring they enhance rather than overshadow the mouse, and render this in a vibrant digital art style with sharp, glowing details and a slightly surreal, immersive atmosphere that captures the thrill of gaming and the pulse of urban innovation, all while excluding any human figures from the composition.
Create a visually captivating image showcasing a stunning “Literary Art Print” as the centerpiece, elegantly displayed on a modern bookshelf in a cozy, Toronto-inspired loft setting, with the city skyline subtly visible through a large window in the background, casting a golden evening glow over the scene; surround the print with hints of Sarah’s creative world—stacked vintage novels, a small paintbrush set, and a vinyl record peeking out from a shelf, all harmoniously arranged to evoke her love for literature, art, and music, without overshadowing the vibrant art print itself; render this composition in a dreamy watercolor style, with soft, flowing colors and delicate brushstroke textures that reflect Sarah’s artistic spirit and add a whimsical, imaginative charm to the promotion.
Create a visually captivating image showcasing a futuristic Smart Irrigation System as the centerpiece, elegantly positioned in a vibrant, blooming garden under the soft, misty light of a Manchester morning, with lush green lawns and colorful flowerbeds stretching into the distance, subtly hinting at Robert’s passion for gardening and DIY through scattered rustic garden tools and a small, weathered workbench tucked into the background, all rendered in a dreamy watercolor style to evoke a sense of creativity and inspiration, ensuring the irrigation system remains the focal point with intricate details of its modern design gleaming with innovation, while the surrounding environment reflects a harmonious blend of nature and practicality without any human presence to distract from the scene.
Create a visually striking image that showcases a pair of top-of-the-line soccer cleats as the central focus, positioned dynamically on a vibrant, sunlit soccer field in the heart of São Paulo, with the city’s iconic skyline faintly visible in the background to reflect Lucas’s urban Brazilian roots, surrounded by subtle hints of his passions like a nearby feijoada pot and a tablet displaying a soccer match streaming, all blended into a lively, energetic scene that captures the spirit of the game, rendered in a bold, colorful digital painting style to evoke the passion and cultural vibrancy of Lucas’s lifestyle, ensuring no humans are present to keep the focus on the cleats and the atmosphere.
Create a captivating image showcasing a sleek, wasserdichte Action-Kamera priced at 129 € as the central focus, mounted on a stylish bicycle handlebar, set against the vibrant, dynamic backdrop of Berlin’s iconic urban landscape at golden hour, with faint traces of graffiti-covered walls and the Spree River shimmering in the distance to reflect Anna’s adventurous, city-exploring spirit as a tech-savvy cyclist and photographer; infuse the scene with subtle details like a camera lens flare catching the light or a hint of a bike path winding through the background, ensuring the Action-Kamera remains the bold centerpiece, and render this composition in a vivid, artistic watercolor style to evoke a sense of creativity and motion that mirrors Anna’s passion for capturing life’s moments through her lens.
Create a vibrant, visually captivating image promoting the premium Beach Gear Kit, placing the kit as the central focus amidst a stylized, sun-drenched coastal scene inspired by Sydney’s iconic beaches, with crashing turquoise waves and golden sands stretching into the horizon, reflecting Michael’s adventurous surfing lifestyle; surround the kit with subtle, non-distracting elements like scattered seashells, a surfboard fin peeking from the sand, and a faint trail of footprints leading toward the ocean, hinting at his love for outdoor exploration and scenic landscapes, while keeping the composition free of humans to emphasize the gear itself; render this scene in a bold, artistic watercolor style, with soft, flowing brushstrokes and vivid blues and yellows, evoking a dreamy yet energetic vibe that captures the essence of a perfect beach day for an adventure enthusiast.
100%|██████████| 10/10 [00:17<00:00, 1.73s/it]
Final Results
Now that we’ve generated images and personas, let’s take a look at how these hyper-personalized marketing pieces come together with their custom visuals to captivate each customer.
Python (OpenAI)
from IPython.display import Image
for index, row in df.iterrows():
print(f"{row['Marketing Piece']}\n")
display(Image(row["image_path"], width=600))
print()
Text
Hey John, ready to level up your gaming on the go? As a tech-savvy New Yorker, we know you love cutting-edge gear. Since your last laptop purchase in January, we’ve got something epic for you—a premium Gaming Mouse, perfect for dominating every match! Snag it now for just $49.99 (exclusive 20% off this week only)! Don’t miss out; this deal won’t last long in the Big Apple. Tap here on your smartphone to grab yours before it’s game over! 🎮💥

Text
Hey Emma, ready to slay this winter in style? As a true London fashionista at 28, we know you love rocking the latest trends with your recent winter coat and boots! We've got an exclusive deal just for you – a stunning Wool-Blend Scarf for only £29.99 to complete your look. Perfect for those chilly London streets! Hurry, this offer is for this week only. Tap now on your tablet to grab it before it’s gone! 🧣 Stay fabulous!

Text
G’day Michael! Ready to elevate your beach game? Since your epic surfboard purchase earlier this year, we’ve got something special for you. Check out our premium Beach Gear Kit—perfect for your surfing adventures in Sydney. It’s packed with essentials (minus the sunscreen you already snagged!) for just $59.99, exclusive to our top adventurers like you. Don’t miss out—this offer rides the wave for this week only! Surf over to our site on your laptop and grab yours now. Let’s hit the beach, mate! 🏄♂️

Text
Hey Sarah, ready to elevate your Toronto pad? We’ve got an exclusive deal just for you—a stunning “Literary Art Print” for only $35! Perfect for your bookshelf vibe, this piece blends your love for literature and art into one masterpiece. Imagine it inspiring your next novel read! But hurry, this offer’s only live this week. Tap now to snag it before it’s gone—crafted just for creative souls like you. Check it out on your smartphone today! 🎨📚

Text
Hey Robert,
Your garden in Manchester is calling for an upgrade! Remember those cracking garden tools you snagged last year? We’ve got something new for you – an exclusive Smart Irrigation System, perfect for your gardening passion and DIY projects. Inspired by your search for garden designs, this £99 gem will save time and keep your lawn lush!
As a top customer, enjoy 15% off this week only. Dive into the details on your desktop and transform your space today. Click now to grab this deal before it’s gone! 🌱

Text
¡Hola, Maria! ¿Lista para brillar este verano en Madrid? Sabemos que amas la moda y el baile, y tras tu última compra de ese vestido fabuloso, ¡tenemos algo especial para ti! Descubre nuestra nueva colección de sandalias de viaje, perfectas para tus aventuras y noches de baile. Solo por esta semana, llévate un par con 20% de descuento. ¡No te lo pierdas! Haz clic ahora desde tu móvil y añade estilo a tus pasos. 💃✨

Text
Olá, Lucas! ⚽
Você, apaixonado por futebol, não pode perder essa! Aqui em São Paulo, sabemos que o jogo nunca para, então trouxemos algo especial pra você. Que tal um par de chuteiras top de linha, perfeitas pra arrasar no campo? Inspirado no seu amor por soccer e nas suas buscas por jogos, oferecemos 20% de desconto só essa semana!
Acesse agora pelo seu tablet e garanta as suas antes que acabem. Vem com a gente, craque!
Clique aqui e marque esse gol!

Text
Hey Anna,
Hast du Lust, deine Radtouren in Berlin auf das nächste Level zu bringen? Als passionierte Radfahrerin (dein Bike-Kauf letztes Jahr war top!) und Fotografie-Liebhaberin haben wir genau das Richtige für dich: Eine wasserdichte Action-Kamera für nur 129 € – perfekt, um deine Abenteuer festzuhalten! Nur diese Woche exklusiv für unsere treuen Kunden. Schau dir die Details auf deinem Laptop an und schnapp dir dieses Angebot, bevor es weg ist! 🚴♀️📸
Klick jetzt und starte dein nächstes Abenteuer!
Liebe Grüße,
Dein Team

Text
प्रिया, नमस्ते! आपके स्टाइल को देखते हुए, हमें लगता है कि आपको हमारी नई "डिज़ाइनर लहंगा चोली" पसंद आएगी, जो बॉलीवुड की चमक से प्रेरित है! 💃 आपके हाल के साड़ी खरीद (अप्रैल 2023) और साड़ी डिज़ाइनों की खोज को ध्यान में रखते हुए, यह खास ऑफर सिर्फ आपके लिए है। इस हफ्ते ही 20% डिस्काउंट पर इसे अपने वॉर्डरोब में शामिल करें! मंबई की गलियों में सबसे स्टाइलिश दिखें। अभी अपने स्मार्टफोन पर क्लिक करें और खरीदें, ऑफर सीमित समय के लिए है!

Text
Hey James, ready to elevate your photography game? We’ve got an exclusive deal just for you, straight from the heart of Los Angeles! Since you snagged that camera and tripod, how about a premium camera lens to capture those epic travel shots and movie-inspired scenes? This week only, grab it at 20% off—perfect for your next adventure. Check out the stunning specs and reviews on your laptop now. Don’t miss out, mate—this deal won’t wait! Click to claim yours today! 📸

Pretty cool!
Conclusion
Starting with nothing, we’ve built a powerful pipeline that runs in the order of minutes to deliver hyper-personalized marketing messages along with custom images for each user. Let's quickly recap some of what we covered:
- Synthetic Data Generation using Structured Outputs
- Using prompt engineering best practices to generate hyper personalized marketing messages
- Using meta prompting to generate prompts optimized for image generation
We only scratched the surface, here are some ideas for you to try to take this even further:
- Update the text generation prompt to incorporate you're organization's brand voice/style guide
- Update the text generation prompt so that it can adhere to a specific template for the generated message.