Transform any media content—text posts, images, or other formats—into rich, detailed personas. This powerful feature enables you to analyze user-generated content and create representative personas for your target audience.
Generate from Social Media Posts
Analyze social media content to understand your audience:
social-media-persona.ts
1import { PersonaBuilder } from '@jamesaphoenix/persona-sdk';2
3// Generate persona from a social media post4const post = `Just crushed a 10k run this morning! 🏃♂️ 5Feeling amazing. Time to refuel with a protein smoothie and 6get some coding done. #morningrun #developerlife`;7
8const persona = await PersonaBuilder.fromPost(post, {9 apiKey: process.env.OPENAI_API_KEY,10 platform: 'twitter' // Optional: twitter, instagram, linkedin11});12
13console.log(persona.toObject());14// Result:15// {16// name: 'Alex Chen',17// age: 28,18// occupation: 'Software Developer',19// interests: ['running', 'fitness', 'coding', 'healthy eating'],20// lifestyle: 'health-conscious, early riser, tech professional',21// personality: 'motivated, disciplined, achievement-oriented'22// }
Generate from Images
Create personas by analyzing image content:
image-persona.ts
1// Generate persona from image analysis2const imageUrl = 'https://example.com/user-photo.jpg';3
4const persona = await PersonaBuilder.fromImage(imageUrl, {5 apiKey: process.env.OPENAI_API_KEY,6 analyzeFor: ['demographics', 'interests', 'lifestyle']7});8
9// Or from local file10const persona = await PersonaBuilder.fromImageFile('./photo.jpg', {11 apiKey: process.env.OPENAI_API_KEY12});13
14// Batch processing for multiple images15const photos = ['photo1.jpg', 'photo2.jpg', 'photo3.jpg'];16const personas = await PersonaBuilder.fromImages(photos, {17 apiKey: process.env.OPENAI_API_KEY,18 groupAnalysis: true // Analyze as a cohesive group19});
Multi-Media Analysis
Combine multiple media sources for richer personas:
multi-media-analysis.ts
1import { MediaAnalyzer, PersonaBuilder } from '@jamesaphoenix/persona-sdk';2
3// Analyze multiple content pieces from one user4const analyzer = new MediaAnalyzer({5 apiKey: process.env.OPENAI_API_KEY6});7
8// Add various media types9analyzer.addPost('Love exploring new coffee shops while working on my startup!');10analyzer.addImage('workspace-photo.jpg');11analyzer.addPost('Just launched our MVP! 3 months of hard work paying off 🚀');12analyzer.addBio('Entrepreneur | Coffee Enthusiast | Building the future');13
14// Generate comprehensive persona15const persona = await analyzer.generatePersona({16 confidence: 'high', // Require high confidence in attributes17 includeInferred: true // Include inferred attributes18});19
20console.log(persona.toObject());21// Result includes deep insights from all media sources
Content Categories
📝 Text Content
- • Social media posts
- • Blog comments
- • Reviews and feedback
- • Forum discussions
- • Chat messages
🖼️ Visual Content
- • Profile photos
- • Lifestyle images
- • Product interactions
- • Environment context
- • Activity photos
Advanced Options
Fine-tune media analysis with advanced configuration:
advanced-media-options.ts
1const persona = await PersonaBuilder.fromPost(content, {2 apiKey: process.env.OPENAI_API_KEY,3 4 // Analysis options5 extractSentiment: true,6 detectPersonality: true,7 inferDemographics: true,8 9 // Confidence thresholds10 minConfidence: 0.7,11 requireExplicitMentions: false,12 13 // Context hints14 domain: 'fitness', // Help focus the analysis15 ageRange: [20, 40], // Constrain demographics16 17 // Output control18 includeRawAnalysis: true,19 generateBackground: true20});21
22// Access detailed analysis23console.log(persona.attributes.sentiment); // positive, neutral, negative24console.log(persona.attributes.personalityTraits); // Big 5 traits25console.log(persona.attributes.confidence); // Confidence scores
✨ Best Practices
- • Privacy First: Always respect user privacy and obtain consent
- • Multiple Sources: Combine different media types for accuracy
- • Context Matters: Provide domain hints for better results
- • Validate Results: Cross-reference with known demographics
- • Batch Processing: Use batch methods for efficiency