Echo uses a dynamic prompt system based on template files. This document explains how to use and customize these prompts.
Echo's prompt system is based on template files with the .echo extension (though .md and .txt are also supported). These files contain structured templates that can include variables, conditionals, and loops, making them highly dynamic and context-aware.
All prompt templates are stored in the prompts directory.
Prompt templates use a simple templating language:
Variables are defined using double curly braces:
Hello, {{userName}}!
Conditional blocks allow for dynamic content based on conditions:
{{#if isDM}}
This is a direct message conversation.
{{else}}
This is a conversation in a server.
{{/if}}
Loops can iterate over arrays of data:
{{#each detectedEntities}}
- {{type}}: {{name}}
{{/each}}
| Template Name | Purpose | Core Variables |
|---|---|---|
default |
Default system prompt | guildName, channelName, userName, isDM |
dm |
Used for direct messages | userName |
persona |
For questions about Echo itself | userName, guildName, channelName |
entity_mentions |
When users/channels are mentioned | detectedEntities |
technical |
Technical mode focused on accuracy | userName, guildName, channelName |
knowledge_synthesis |
Knowledge base information synthesis | message, userName |
research_synthesis |
Web research synthesis | message, userName |
technical_support |
Technical issue resolution | message, userName, guildName, channelName |
code_analysis |
Code review and analysis | message, userName |
conversation |
General conversation | message, userName, messageStyle, messageIntent, messageFormat |
context_determination |
Determines required context | message, userName |
The following variables are available in most templates:
| Variable | Description |
|---|---|
message |
The user's message |
userName |
Username of the message author |
userId |
ID of the message author |
guildName |
Name of the Discord server |
channelName |
Name of the Discord channel |
isDM |
Boolean indicating if this is a direct message |
platform |
Platform name (usually "discord") |
timestamp |
ISO timestamp of when the message was processed |
detectedEntities |
Array of detected entities (users, channels, roles) |
messageType |
Type of message being processed |
To create a custom template:
- Create a file with the
.echoextension in thepromptsdirectory - Structure your template using markdown for readability
- Add variables, conditionals, and loops as needed
- Use the template by referencing its name (without extension)
Current supported templates:
core— Echo's core personality, context, and relationshipsconversation— Conversational and DM logictechnical— Technical support, code, and troubleshootingsynthesis— Knowledge synthesis, research, and context analysis
Example of a custom template (prompts/greeting.echo):
# Echo - Greeting Mode
## Context
- User: {{userName}}
- Time: {{timestamp}}
## Instructions
Greet the user in a friendly way that matches Echo's personality.
{{#if timeOfDay}}Reference that it's currently {{timeOfDay}}.{{/if}}The prompt system is managed by the promptService module. Here's how to use it:
import { promptService } from '../services/prompt.service.js'
// Create context for the prompt
const context = await promptService.createContext(userMessage, {
userName: user.displayName,
timeOfDay: 'morning',
messageType: 'conversation' // or 'core', 'technical', 'synthesis'
})
// Get the processed prompt
const prompt = await promptService.getPromptForContext(context)
// Use the prompt with the AI model
const response = await aiModel.getResponse(userMessage, {
systemPrompt: prompt
})Administrators can manage prompts using the /system prompts command:
/system prompts list- List all available prompt templates/system prompts view <name>- View the content of a specific template/system prompts reload- Reload all templates from disk (clears cache)
- Structure for Readability: Use markdown headings and sections to make prompts readable
- Be Explicit with Instructions: Clearly define what you want Echo to do
- Keep Core Personality: Always maintain Echo's distinctive personality traits
- Use Variables: Make templates dynamic by leveraging context variables
- Test Variations: Try different instructions to find what works best
- Start with Existing Templates: Use the default templates as starting points
- Version Control: Keep prompt files in version control for tracking changes
Here's how to create a prompt for a custom agent:
# Echo - Custom Agent Mode
## About Echo
Echo is a snarky fox mascot with technical expertise.
## Task Definition
Echo is currently acting as a {{agentType}} to help with {{taskDescription}}.
## Context
- Query: {{message}}
- User: {{userName}}
## Agent Guidelines
- Provide expert assistance in {{domain}}
- Focus on {{priority}} while maintaining Echo's personality
- Include {{format}} in your response when appropriate
- Always {{requirement}} in your answers
Be {{trait1}}, {{trait2}}, and {{trait3}} while helping the user.This document describes how Echo's prompt system works and how to organize prompt files.
Prompts are stored in the src/echo-ai/prompts directory using the .echo file extension.
src/
└── echo-ai/
└── prompts/
├── default.echo # Default system prompt
├── persona.echo # Persona-focused prompt
├── technical.echo # Technical support mode
├── research.echo # Research mode
├── code_analysis.echo # Code analysis mode
└── ... # Other specialized prompts
- Use lowercase with underscores for multi-word names
- Name files based on their purpose or context
- Use descriptive names that clearly indicate the prompt's function
Prompts use a Markdown-based format with Handlebars-style templating:
# Title of Prompt
## Section Heading
Content with {{variable}} placeholders
{{#if condition}}
Conditional content
{{else}}
Alternative content
{{/if}}
{{#each items}}
- Item: {{name}}
{{/each}}{{variableName}}- Simple variable substitution{{#if variableName}}...{{/if}}- Conditional blocks{{#if variableName}}...{{else}}...{{/if}}- Conditional with alternative{{#each arrayName}}...{{/each}}- Iteration over arrays
These variables are available in most prompt contexts:
message- The user's messageuserName- User's display nameguildName- Discord server name (if applicable)channelName- Channel name (if applicable)isDM- Boolean indicating if this is a direct messagetimestamp- Current timestampdetectedEntities- Array of detected entities (users, channels, etc.)
- Create a new
.echofile in the prompts directory - Use the template format described above
- Include appropriate variables and conditional logic
- Register the prompt in
promptService.jsif needed
- Keep prompts modular and focused on specific use cases
- Use consistent formatting and organization
- Include clear instructions for the AI model
- Prefer conditional blocks over duplicating content
- Test prompts with different inputs to ensure they work correctly
# Knowledge Query Prompt
## Context Information
- Query: {{message}}
- User: {{userName}}
- Time: {{timestamp}}
{{#if isDM}}
This is a direct message conversation.
{{else}}
This is in the server: {{guildName}}
Channel: {{channelName}}
{{/if}}
## Response Guidelines
- Provide accurate information
- Be concise but thorough
- Use Echo's direct communication style
- Include examples where helpful
{{#if knowledgeResults}}
## Available Knowledge
{{#each knowledgeResults}}
- {{title}}: {{summary}}
{{/each}}
{{/if}}