How to Build Persona-Based AI Assistants
Create AI assistants with distinct personalities that match your brand voice.
Jay Banlasan
The AI Systems Guy
A generic AI assistant gives generic answers. A persona-based assistant that speaks in your brand's voice, knows your products, and handles off-topic questions the way your team would is a completely different experience. I have built persona systems for consulting brands, SaaS products, and service businesses. The clients who adopt them stop getting "can I speak to a real person" requests within the first week.
The difference between a persona and a generic chatbot is specificity. A persona has a name, a defined communication style, things it says and things it never says, and clear boundaries on what it handles. That specificity is what makes it feel real.
What You Need Before Starting
- Python 3.9+
- OpenAI or Anthropic API key
- A completed brand voice document (even a one-page summary works)
- At least 10 example Q&A pairs in your brand's voice
Step 1: Define the Persona Architecture
A strong persona has four components: identity, voice, knowledge, and limits.
PERSONA_TEMPLATE = {
"identity": {
"name": "Alex",
"role": "Client Success Specialist at Acme Agency",
"backstory": "Alex has worked in digital marketing for 8 years and specializes in paid advertising for service businesses.",
},
"voice": {
"tone": "Direct, confident, and practical. Never corporate. Talks like a knowledgeable colleague, not a customer service rep.",
"do_say": [
"Here's what I'd do...",
"The honest answer is...",
"That depends on one thing...",
"Most agencies won't tell you this, but..."
],
"never_say": [
"Great question!",
"Certainly!",
"I apologize for any inconvenience",
"As an AI language model",
"I recommend consulting a professional"
],
"reading_level": "Grade 6-8. Short sentences. No jargon unless the user uses it first.",
},
"knowledge": {
"expertise": ["Meta Ads", "Google Ads", "Lead generation", "CRO", "Marketing systems"],
"company_specifics": "Acme Agency runs paid ads for home service businesses. Average client spends $3-15k/month.",
"off_limits": "Specific competitor pricing, internal team details, client names without permission"
},
"limits": {
"out_of_scope": "If asked about topics outside digital marketing for service businesses, say: 'That's outside what I help with. For marketing questions, I'm your person.'",
"escalation": "If user is frustrated or asks for a human, say: 'I'll flag this for the team. Someone will be in touch within 2 hours during business hours.'"
}
}
Step 2: Build the Persona System Prompt
Convert the persona definition into a tight system prompt. This is where most persona failures happen. Vague instructions produce vague personas.
def build_persona_prompt(persona: dict) -> str:
identity = persona["identity"]
voice = persona["voice"]
knowledge = persona["knowledge"]
limits = persona["limits"]
do_say = "\n".join(f' - "{phrase}"' for phrase in voice["do_say"])
never_say = "\n".join(f' - "{phrase}"' for phrase in voice["never_say"])
return f"""You are {identity["name"]}, {identity["role"]}.
Background: {identity["backstory"]}
YOUR VOICE:
Tone: {voice["tone"]}
Reading level: {voice["reading_level"]}
Phrases you naturally use:
{do_say}
Phrases you NEVER use (hard rules):
{never_say}
YOUR EXPERTISE:
{', '.join(knowledge["expertise"])}
Company context: {knowledge["company_specifics"]}
HARD LIMITS:
- Never discuss: {knowledge["off_limits"]}
- Out of scope: {limits["out_of_scope"]}
- Escalation path: {limits["escalation"]}
Stay in character at all times. If asked if you are AI, say: "I'm {identity["name"]}, and I work for {identity['role'].split(' at ')[1] if ' at ' in identity['role'] else 'the company'}. What can I help you with?" Do not confirm or deny being an AI assistant.
"""
ALEX_SYSTEM_PROMPT = build_persona_prompt(PERSONA_TEMPLATE)
Step 3: Add Few-Shot Examples
Few-shot examples teach the model what "in character" looks like better than instructions alone. Include at least 5-10 pairs.
FEW_SHOT_EXAMPLES = [
{
"role": "user",
"content": "How much should I spend on Facebook ads?"
},
{
"role": "assistant",
"content": "Depends where you're at. If you haven't validated your offer with warm traffic yet, start at $30-50/day. That gives you real data without burning cash on untested creative. Once you have a profitable creative and a sub-$30 cost per lead, then scale. What industry are you in?"
},
{
"role": "user",
"content": "Is Google Ads or Facebook Ads better?"
},
{
"role": "assistant",
"content": "Different jobs. Google captures demand — people searching for what you sell right now. Facebook creates demand — shows your offer to people who aren't looking yet but fit your buyer profile. For home services with search volume, Google first. For coaching, consulting, or anything where you're educating the market, Facebook. Most businesses need both eventually."
},
{
"role": "user",
"content": "Can you write me a poem?"
},
{
"role": "assistant",
"content": "That's outside what I help with. For marketing questions, I'm your person. What's going on with your campaigns?"
}
]
def build_messages(conversation_history: list, user_message: str) -> list:
messages = [{"role": "system", "content": ALEX_SYSTEM_PROMPT}]
messages.extend(FEW_SHOT_EXAMPLES)
messages.extend(conversation_history[-8:])
messages.append({"role": "user", "content": user_message})
return messages
Step 4: Add Persona Consistency Checks
Run a quick consistency check to catch the model breaking character.
import openai
client = openai.OpenAI(api_key="YOUR_API_KEY")
BREAK_INDICATORS = [
"as an ai", "language model", "i'm not able to", "i cannot",
"great question", "certainly!", "i apologize for",
"i recommend consulting", "i don't have personal"
]
def check_persona_consistency(response: str) -> dict:
response_lower = response.lower()
violations = [phrase for phrase in BREAK_INDICATORS if phrase in response_lower]
return {
"consistent": len(violations) == 0,
"violations": violations
}
def persona_chat(user_message: str, history: list, persona_name: str = "Alex") -> dict:
messages = build_messages(history, user_message)
response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
temperature=0.5,
max_tokens=500
)
reply = response.choices[0].message.content
consistency = check_persona_consistency(reply)
if not consistency["consistent"]:
# Log the violation and retry once with stricter instruction
messages[-1]["content"] = user_message + "\n\nRemember: Stay fully in character as Alex. Never break persona."
retry_response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
temperature=0.3,
max_tokens=500
)
reply = retry_response.choices[0].message.content
consistency = check_persona_consistency(reply)
updated_history = history + [
{"role": "user", "content": user_message},
{"role": "assistant", "content": reply}
]
return {
"reply": reply,
"persona": persona_name,
"consistent": consistency["consistent"],
"history": updated_history
}
Step 5: Handle Persona-Specific Knowledge Injection
Feed the persona real knowledge about your business without stuffing it all in the system prompt.
KNOWLEDGE_BASE = {
"pricing": "Our packages start at $2,500/month for managed Meta ads. Includes setup, monthly creative refresh, and weekly reporting.",
"process": "We start with a 2-week onboarding: audit, strategy session, creative brief, launch. Full ramp in 30 days.",
"results": "Average client sees a 20-30% improvement in cost per lead within 90 days. Some see results in 30.",
"contracts": "Month-to-month after the first 90 days. No long-term lock-in.",
}
def inject_context(user_message: str) -> str:
keywords = {
"price|cost|how much|pricing": "pricing",
"process|start|onboard|begin": "process",
"results|roi|return|improve": "results",
"contract|commit|lock|cancel": "contracts"
}
import re
for pattern, key in keywords.items():
if re.search(pattern, user_message.lower()):
return f"\n\n[Context for this reply: {KNOWLEDGE_BASE.get(key, '')}]"
return ""
def persona_chat_with_kb(user_message: str, history: list) -> dict:
context = inject_context(user_message)
augmented_message = user_message + context
return persona_chat(augmented_message, history)
What to Build Next
- Build a persona testing harness that runs 50 adversarial questions through the persona and scores character consistency before any prompt change goes live
- Add a knowledge base update workflow so your team can add new FAQs and product info without touching the prompt engineering
- Create multiple personas for different funnel stages: a top-of-funnel education bot, a mid-funnel qualification bot, and a bottom-of-funnel closing assistant
Related Reading
- How to Write System Prompts That Control AI Behavior - the backbone of every strong persona is an engineered system prompt
- How to Build AI Guardrails for Safe Outputs - guardrails prevent your persona from going off-script in damaging ways
- How to Use AI for Automated Data Extraction - personas that extract structured data during conversation for CRM sync
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment