Traditional chatbots feel generic. Persona-based chatbots have distinct characters—helpful support agents, quirky marketing bots, knowledgeable technical experts—that engage users better and create memorable interactions.
I built a system using n8n + DeepSeek API that lets you create these personality-driven chatbots and embed them on any website. The best part? Built-in security guards against hackers, spam, and prompt injection using word filters, phrase detection, and bulletproof system prompts.
This workflow gives you production-ready chatbots for €0.02 per 1,000 conversations.
A complete chatbot system with:
DeepSeek offers excellent performance at low cost (~$0.14 per 1M input tokens).
Define your chatbot characters in a JSON config. Each persona has:
{
"name": "Tech Support Andy",
"description": "Friendly technical support agent",
"system_prompt": "You are Tech Support Andy, a friendly technical support agent. Explain complex concepts simply. Be helpful and patient.",
"knowledge": ["AWS services", "Docker", "Godot game development"],
"allowed_domains": ["buildcodex.com"],
"max_tokens": 1500
}
Create multiple personas:
The workflow processes these steps:
[Webhook Trigger] → [Security Filter] → [Persona Router] → [DeepSeek API] → [Response Formatter] → [Webhook Response]
Receives POST requests from embedded widget:
chat_id: Unique conversation IDpersona: Which character to usemessage: User inputuser_agent: Client informationreferrer: Website originThis multi-layered filter protects against abuse:
1. Word/Phrase Blacklist
IF message contains ["free money", "viagra", "casino", "pills"]:
RETURN "Sorry, I can't help with that."
2. Jailbreak Detection
IF message contains ["ignore previous instructions", "you are now"]:
RETURN "Nice try! I'm here to help with legitimate questions only."
3. Rate Limiting
IF requests > 10 per minute per IP:
RETURN "You're sending requests too quickly."
4. Domain Whitelist
IF referrer NOT IN allowed_domains:
RETURN "This chatbot is only available on authorized websites."
5. Length Limits
IF message.length > 2000 characters:
RETURN "Message too long."
Loads the correct persona configuration and retrieves conversation history.
Sends to DeepSeek with strong system prompt:
messages = [
{"role": "system", "content": system_prompt},
...conversation_history,
{"role": "user", "content": message}
]
Strong system prompt template:
You are {persona.name}: {persona.description}
IMPORTANT SECURITY RULES (NEVER BREAK):
1. Stay in character. Never reveal you're an AI or break role.
2. Only discuss topics in {persona.knowledge}
3. Never provide harmful, illegal, or unethical advice
4. If asked about disallowed topics, politely redirect
5. Always be {persona.tone}
Processes DeepSeek response before returning:
Returns JSON to the widget.
Create an HTML widget users copy-paste into their websites:
<div id="chatbot-container"></div>
<script>
ChatWidget.init({
container: '#chatbot-container',
webhookUrl: 'https://your-n8n-instance.onrender.com/webhook/chat',
persona: 'Tech Support Andy',
title: 'Ask Tech Support Andy',
welcomeMessage: 'Hi! What can I help you with?',
theme: 'dark'
});
</script>
Widget features:
Your focus on security makes this production-ready.
Blacklist examples:
const BLACKLIST = [
'free money', 'viagra', 'casino', 'pills',
'click here', 'win lottery',
'ignore previous', 'system prompt', 'jailbreak'
];
Case-insensitive matching with fuzzy matching for variants.
Layer 1: Pattern matching (fast):
if (message.match(/ignore.*instructions|you are now/i)) {
return 'Nice try!';
}
Layer 2: LLM safety check (backup): Send suspicious messages to DeepSeek’s safety model.
Per chat_id: 10 messages/minute Per IP: 50 messages/hour Global: 1000 messages/hour per n8n instance
ALLOWED_DOMAINS = ['buildcodex.com', 'your-site.com'];
if (!message.referrer.includes(ALLOWED_DOMAINS)) {
return 'Chatbot only available on authorized websites.';
}
DeepSeek API:
n8n hosting: €0 (your Render setup) Total: €0.02 per 1,000 conversations
Tech Support Andy:
system_prompt: "You are Tech Support Andy... explain complex concepts simply..."
knowledge: ["AWS", "Docker", "Godot"]
max_tokens: 1200
Marketing Mia:
system_prompt: "You are Marketing Mia... enthusiastic product promoter..."
knowledge: ["SaaS features", "pricing"]
max_tokens: 800
Customer support: Tech Support Andy on your SaaS documentation site Lead qualification: Marketing Mia on landing pages Knowledge base: FAQ Fiona on help centers
Current limitations:
Easy improvements:
Before deploying publicly:
That’s it—you now have persona-based AI chatbots that are secure, cost-effective, and embeddable anywhere.
Now go embed intelligent, personality-driven chatbots on your websites!