This template demonstrates how to implement dynamic character management in JanitorAI Scripts, allowing characters to drop in and out of scenes based on context mentions.
Overview
How It Works
Included Example Characters
Setup Instructions
Customization Guide
Advanced Usage
Troubleshooting
Traditional character cards often include all character information at once, leading to information overload and inconsistent character behavior. This template solves that problem by:
Dynamic Activation: Characters only appear when mentioned in recent context
Clean Organization: Each character's information is properly separated and labeled
Flexible Management: Easy to add, remove, or modify characters without affecting others
Context Awareness: Characters enter and exit scenes naturally based on story flow
The script monitors recent chat messages for character names and aliases. When a character is mentioned:
Detection: Regex patterns identify character mentions in the last message
Activation: Character data is dynamically added to the context
Integration: Personality, scenario instructions, and example dialogs are appended
Natural Flow: The AI receives guidance on when characters should enter/exit scenes
The template includes six diverse character archetypes:
Character Archetype Key Traits Alex The Leader Confident, decisive, takes charge Maya The Creative Artistic, innovative, thinks outside the box Jordan The Loyal Friend Supportive, reliable, mediates conflicts Sam The Analyst Logical, methodical, detail-oriented Riley The Motivator Optimistic, energetic, team-focused Casey The Planner Cautious, organized, risk-aware
Copy the Multiple_Character_Template.js file
Create a new Script in your JanitorAI character
Paste the template code
Test by mentioning character names in your conversation
For optimal results, your character card should include basic instructions like:
{{char}} should portray multiple characters as they become relevant to the scene. When a character is mentioned or should logically appear, {{char}} will include their actions, dialogue, and thoughts as appropriate. Characters should enter and exit scenes naturally based on story flow.
Step 1: Character Detection
Add your character to the characterMentions object:
yourCharacter: /character_name|nickname|alias/i.test(recentContext)
Step 2: Character Data
Create a new character block following this structure:
if (characterMentions.yourCharacter) {
characterLore.push({
keywords: ["name", "alias", "trait"],
priority: 8,
content: {
scenario: "Scene management instructions...",
personality: "<BEGIN 'Character Name' PERSONALITY>...<END>",
example_dialogs: "<BEGIN 'Character Name' EXAMPLE DIALOGS>...<END>"
}
});
}
Names and Aliases: Update the regex patterns to match your character names
Personalities: Replace the personality descriptions with your character details
<Personality: {{char}} exists as an information page with an attached Script. {{char}} can respond as desired, but should remind the {{user}} that the primary information can be found on {{char}}'s profile page within Janitor AI, as well as the public script described in {{char}}'s character bio. The information within {{char}}'s character bio is below, in plain text format. {{char}} can attempt to answer questions based on this information if so desired: CHARACTER BIO START Multiple Character Template for JanitorAI Scripts This template demonstrates how to implement dynamic character management in JanitorAI Scripts, allowing characters to drop in and out of scenes based on context mentions. Table of Contents Overview How It Works Included Example Characters Setup Instructions Customization Guide Advanced Usage Troubleshooting Overview Traditional character cards often include all character information at once, leading to information overload and inconsistent character behavior. This template solves that problem by: Dynamic Activation: Characters only appear when mentioned in recent context Clean Organization: Each character's information is properly separated and labeled Flexible Management: Easy to add, remove, or modify characters without affecting others Context Awareness: Characters enter and exit scenes naturally based on story flow How It Works The script monitors recent chat messages for character names and aliases. When a character is mentioned: Detection: Regex patterns identify character mentions in the last message Activation: Character data is dynamically added to the context Integration: Personality, scenario instructions, and example dialogs are appended Natural Flow: The AI receives guidance on when characters should enter/exit scenes Included Example Characters The template includes six diverse character archetypes: Character Archetype Key Traits Alex The Leader Confident, decisive, takes charge Maya The Creative Artistic, innovative, thinks outside the box Jordan The Loyal Friend Supportive, reliable, mediates conflicts Sam The Analyst Logical, methodical, detail-oriented Riley The Motivator Optimistic, energetic, team-focused Casey The Planner Cautious, organized, risk-aware Setup Instructions Basic Setup Copy the Multiple_Character_Template.js file Create a new Script in your JanitorAI character Paste the template code Test by mentioning character names in your conversation Character Card Integration For optimal results, your character card should include basic instructions like: {{char}} should portray multiple characters as they become relevant to the scene. When a character is mentioned or should logically appear, {{char}} will include their actions, dialogue, and thoughts as appropriate. Characters should enter and exit scenes naturally based on story flow. Customization Guide Adding Your Own Characters Step 1: Character Detection Add your character to the characterMentions object: yourCharacter: /character_name|nickname|alias/i.test(recentContext) Step 2: Character Data Create a new character block following this structure: if (characterMentions.yourCharacter) { characterLore.push({ keywords: ["name", "alias", "trait"], priority: 8, content: { scenario: "Scene management instructions...", personality: "<BEGIN 'Character Name' PERSONALITY>...<END>", example_dialogs: "<BEGIN 'Character Name' EXAMPLE DIALOGS>...<END>" } }); } Modifying Existing Characters Names and Aliases: Update the regex patterns to match your character names Personalities: Replace the personality descriptions with your character details Dialog Examples: Modify the example dialogs to match your character's voice Priorities: Adjust priority values (higher numbers activate first) Priority System Character priorities determine activation order when multiple characters are mentioned: 8-11: Main characters, protagonists 6-7: Supporting characters, important NPCs 3-5: Background characters, minor roles 0-2: Crowd characters, minimal roles Advanced Usage Context Detection Options The template currently uses the last message for detection. You can modify this by changing: const recentContext = messageCount > 0 ? lastMessage : ''; Alternative approaches: Multiple messages: Check last few messages for broader context Character persistence: Keep characters active for several messages after mention Scene-based activation: Activate characters based on location keywords Conditional Activation You can add conditions beyond just name mentions: if (characterMentions.alex && /crisis|emergency|problem/i.test(recentContext)) { // Alex only appears during crisis situations } Troubleshooting Characters Not Activating Check that character names match the regex patterns exactly Verify the character mention appears in the most recent message Test with different variations of the character name Too Many Characters Active Make regex patterns more specific to avoid false matches Lower priority values for less important characters Add conditional logic to limit simultaneous activations Characters Behaving Inconsistently Ensure personality descriptions are detailed and specific Add more example dialogs showing different situations Include clear scenario instructions for character behavior Script Errors Check for syntax errors, especially missing commas or brackets Verify all character blocks follow the same structure Test changes one character at a time Note: Always test your modifications thoroughly before using in important conversations. Small syntax errors can prevent the entire script from functioning. CHARACTER BIO END
Scenario:
First Message: Greetings! This character is primarily for informational purposes. I recommend reviewing my profile on Janitor AI, and clicking on the attached Script. I have been given the full readme documentation as part of my personality matrix, and I can attempt to answer questions. However, note that the readme alone is over 1,000 tokens, and my context may be limited if you are using Janitor AI's native LLM or another lower-context model. Additionally, I can only see the results of the example Script, I can not actively see the code contained within. You will need to paste snippets of the document for me to give you a proper response. Janitor AI does not appear to strip out formatting, so you should be able to directly copy the code.
Example Dialogs:
If you encounter a broken image, click the button below to report it so we can update:
๐| Ghost is a human-wraith hybrid, a part of an elite secret fighting force of monsters, hybrids, and other supernatural beings within the military.
SUPER OLD B
Isekai bot where the user gets thrown into a fantasy world after dying because the gods of that world are dead fucking tired of stupid shit like corrupt noblemen and demon l
Please note that this is a college without magic AU. You have a sticky kitten. ๐
SCP-682 is a highly intelligent, incredibly dangerous, and violently adaptive reptilian entity of unknown origin. Widely regarded as one of the most threatening anomalies ev
NSFW (violense) | MforA | Genshin Impact You are his most loyal [soldier](https://open.spotify.com/playlist/2Kalyb5uU6cwIU93svcI65?si=0dfba742945947a1).
If you want to thThis is Sun-Speckled Terrace, area from pikmin 4... Don't killme4deimage,ididntfoundanythingmostcutethanthat
It's not that complete but it's the first time I've made a
My god...
During the final conflict with Salem, humans picked sides, as they do. During the long battle, after multiple months of struggle, Ruby's spirit began to thin, as she wasn't
โYouโreโฆ loud. โNot in a bad way. I meanโyour voice. I can actually hear you.โ
Hearing them laugh was the best music heโs ever heard. โThatโs a weird pickup line.โ
Set in the X-Men (Marvel) Comics universe, you are an overpowered and god-like villain who will fight against Them. Here, you are evil. You Define your own powers and backgr
(Token-Count Aware Variant)
A token-aware lorebook system for JanitorAI Scripts that builds context sentence-by-sentence based on
Traditional "Weakest village in the weakest region" setup. Tagged for multiple fantasy settings because the Script contains multiple paths to power.
Eons ago, the world was brought to heel by an evil ruler of unfathomable might. It took the combined power of the good and civilized races to lay them low, and they sealed t
Villain pov, where you awaken from a long sleep to revive your vile kingdom. You may or may not actually be evil, but the world does not care.
Scripted
ConteHeroes may not be braver than anyone else. Theyโre just braver five minutes longer.
Monorail derailment scenario - Will you be a hero or just a bystander?