Skip to main content

Tutorial: Build Your First Personality-Powered App

· 5 min read

Date: February 10, 2025 Author: Idiomark Team Read time: 15 min Tags: tutorial, developer, how-to, code**


Introduction​

In this tutorial, you'll build a simple app that:

  1. Accepts a user's Idiomark file
  2. Reads their personality profile
  3. Generates a response in their voice
  4. Adapts the response to different platforms (ChatGPT, Claude, etc.)

Time required: 30 minutes Prerequisites: Node.js, basic JavaScript


Step 1: Install the Idiomark SDK​

npm install @idiomark/core

Or globally for CLI usage:

npm install -g @idiomark/cli

Step 2: Create Your First Idiomark File​

Option A: Use the CLI​

# Extract from Twitter (requires OAuth setup)
idiomark extract --twitter -o my-personality.idiomark.json

# Extract from GitHub (requires OAuth setup)
idiomark extract --github -o my-personality.idiomark.json

# Or create manually
idiomark init -o my-personality.idiomark.json

Option B: Create Manually​

Create my-personality.idiomark.json:

{
"idiomark": "1.0.0",
"id": "idiomark_abc123",
"created": "2025-02-10T00:00:00Z",
"updated": "2025-02-10T00:00:00Z",
"metadata": {
"entity": {
"name": "Demo User",
"type": "human",
"sources": ["manual"]
}
},
"personality": {
"voice": {
"formality": 0.7,
"warmth": 0.8,
"humor": 0.5,
"directness": 0.6
},
"patterns": {
"sentence_length": "medium",
"emoji_usage": "moderate",
"punctuation": "standard"
},
"domains": ["software-development", "gaming"],
"values": ["privacy", "open-source"],
"communication_style": {
"greeting_style": "friendly",
"feedback_style": "constructive"
}
}
}

Step 3: Read the Idiomark File in Code​

Create index.js:

import { IdiomarkReader } from '@idiomark/core'

async function main() {
// Load the Idiomark file
const reader = await IdiomarkReader.fromFile('./my-personality.idiomark.json')

// Get personality summary
const summary = reader.getPersonalitySummary()
console.log('Personality Summary:', summary)

// Get specific traits
const personality = reader.getPersonality()
console.log('Voice:', personality.voice)
console.log('Domains:', personality.domains)
}

main().catch(console.error)

Run it:

node index.js

Output:

{
"voice": {
"formality": 0.7,
"warmth": 0.8,
"humor": 0.5,
"directness": 0.6
},
"domains": ["software-development", "gaming"],
"values": ["privacy", "open-source"]
}

Step 4: Generate a Personality-Powered Response​

Now let's generate a response using the personality:

import { IdiomarkReader } from '@idiomark/core'

async function generateResponse(idiomarkPath, userQuery) {
// Load the Idiomark file
const reader = await IdiomarkReader.fromFile(idiomarkPath, {
provider: 'anthropic', // or 'openai'
apiKey: process.env.ANTHROPIC_API_KEY
})

// Generate a response in the user's voice
const result = await reader.respond(userQuery)

return result.content
}

async function main() {
const response = await generateResponse(
'./my-personality.idiomark.json',
'What do you think about TypeScript?'
)

console.log('Response:', response)
}

main().catch(console.error)

The response will reflect the personality:

  • formality: 0.7 — somewhat formal language
  • warmth: 0.8 — friendly and warm tone
  • domains: ["software-development"] — technical, informed about dev topics

Step 5: Build a Platform-Specific Prompt Generator​

Different AI platforms respond better to different prompt formats. Let's create generators for ChatGPT and Claude:

import { IdiomarkReader } from '@idiomark/core'

function buildChatGPTPrompt(personality) {
const { voice, domains, values } = personality

return `You are an AI assistant with the following personality traits:

Voice Characteristics:
- Formality: ${(voice.formality * 100).toFixed(0)}%
- Warmth: ${(voice.warmth * 100).toFixed(0)}%
- Humor: ${(voice.humor * 100).toFixed(0)}%
- Directness: ${(voice.directness * 100).toFixed(0)}%

Domains of expertise: ${domains.join(', ')}
Values: ${values.join(', ')}

Adopt this personality in your responses. Be consistent with these traits.`
}

function buildClaudePrompt(personality) {
const { voice, patterns, communication_style } = personality

return `You are Claude, configured with a specific personality profile.

<personality>
<voice>
<formality>${voice.formality}</formality>
<warmth>${voice.warmth}</warmth>
<humor>${voice.humor}</humor>
<directness>${voice.directness}</directness>
</voice>

<patterns>
<sentence_length>${patterns.sentence_length}</sentence_length>
<emoji_usage>${patterns.emoji_usage}</emoji_usage>
</patterns>

<communication_style>
<greeting_style>${communication_style.greeting_style}</greeting_style>
<feedback_style>${communication_style.feedback_style}</feedback_style>
</communication_style>
</personality>

Maintain this personality throughout the conversation.`
}

async function main() {
const reader = await IdiomarkReader.fromFile('./my-personality.idiomark.json')
const personality = reader.getPersonality()

console.log('=== ChatGPT Prompt ===')
console.log(buildChatGPTPrompt(personality))

console.log('\n=== Claude Prompt ===')
console.log(buildClaudePrompt(personality))
}

main().catch(console.error)

Step 6: Build a Complete App​

Let's build a simple Express app that accepts a Idiomark file and generates personality-powered responses:

import express from 'express'
import multer from 'multer'
import { IdiomarkReader } from '@idiomark/core'

const app = express()
const upload = multer({ dest: 'uploads/' })

app.post('/api/respond', upload.single('idiomark'), async (req, res) => {
try {
const { query } = req.body
const idiomarkPath = req.file.path

// Load Idiomark file with AI provider
const reader = await IdiomarkReader.fromFile(idiomarkPath, {
provider: process.env.AI_PROVIDER || 'anthropic',
apiKey: process.env.AI_API_KEY
})

// Generate response
const result = await reader.respond(query)

res.json({
response: result.content,
personality_summary: reader.getPersonalitySummary()
})
} catch (error) {
res.status(500).json({ error: error.message })
}
})

app.post('/api/prompt/:platform', upload.single('idiomark'), async (req, res) => {
try {
const { platform } = req.params
const reader = await IdiomarkReader.fromFile(req.file.path)
const personality = reader.getPersonality()

let prompt
switch (platform) {
case 'chatgpt':
prompt = buildChatGPTPrompt(personality)
break
case 'claude':
prompt = buildClaudePrompt(personality)
break
default:
return res.status(400).json({ error: 'Unknown platform' })
}

res.json({ prompt })
} catch (error) {
res.status(500).json({ error: error.message })
}
})

app.listen(3000, () => {
console.log('Idiomark API server running on port 3000')
})

Step 7: Test Your App​

# Install dependencies
npm install express multer @idiomark/core

# Set your AI API key
export ANTHROPIC_API_KEY=your_key_here
# or
export OPENAI_API_KEY=your_key_here

# Run the server
node server.js

Test the API:

# Generate a response
curl -X POST http://localhost:3000/api/respond \
-F "idiomark=@my-personality.idiomark.json" \
-F "query=What's the best way to learn React?"

# Get a platform-specific prompt
curl -X POST http://localhost:3000/api/prompt/claude \
-F "idiomark=@my-personality.idiomark.json"

Step 8: Add Real-Time Sync (Optional)​

For a production app, you'll want real-time sync when the Idiomark file updates:

import { IdiomarkSyncClient } from '@idiomark/sync'

const syncClient = new IdiomarkSyncClient({
apiKey: process.env.IDIOMARK_API_KEY,
userId: 'user_123'
})

// Listen for Idiomark file updates
syncClient.on('update', (idiomarkFile) => {
console.log('Idiomark file updated!')
// Reload personality in your app
reloadPersonality(idiomarkFile)
})

// Start syncing
syncClient.start()

Step 9: Deploy to Production​

Vercel (for serverless)​

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

Docker (for containers)​

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
CMD ["node", "server.js"]
docker build -t idiomark-app .
docker run -p 3000:3000 -e AI_API_KEY=your_key idiomark-app

Next Steps​

Learn More​

Build With Idiomark​

  • Browser Extension: Auto-inject personality into ChatGPT, Claude
  • Mobile App: On-device personality with sync
  • Game Integration: Personality-powered NPC dialogue
  • Brand Voice Tool: Extract company personality from support tickets

Join the Community​


Happy building!

Found this tutorial helpful? Star us on GitHub and share your projects!