Complete Developer Guide
Comprehensive technical documentation for the bootstrap plugin’s architecture, components, and implementation
Overview
The @elizaos/plugin-bootstrap
package is the core message handler for ElizaOS agents. It provides the fundamental event handlers, actions, providers, evaluators, and services that enable agents to process messages from any communication platform (Discord, Telegram, message bus server, etc.) and generate intelligent responses.
This plugin is essential for any ElizaOS agent as it contains the core logic for:
- Processing incoming messages
- Determining whether to respond
- Generating contextual responses
- Managing agent actions
- Evaluating interactions
- Maintaining conversation state
Architecture Overview
Message Processing Flow
1. Message Reception
When a message arrives from any platform (Discord, Telegram, etc.), it triggers the MESSAGE_RECEIVED
event, which is handled by the messageReceivedHandler
.
2. Initial Processing
3. Should Respond Logic
The agent determines whether to respond based on:
- Room type (DMs always get responses)
- Agent state (muted/unmuted)
- Message content analysis
- Character configuration
4. Response Generation
If the agent decides to respond:
- Compose state with relevant providers
- Generate response using LLM
- Parse XML response format
- Execute actions
- Send response via callback
Core Components
Event Handlers
Event handlers process different types of events in the system:
Event Type | Handler | Description |
---|---|---|
MESSAGE_RECEIVED | messageReceivedHandler | Main message processing handler |
VOICE_MESSAGE_RECEIVED | messageReceivedHandler | Handles voice messages |
REACTION_RECEIVED | reactionReceivedHandler | Stores reactions in memory |
MESSAGE_DELETED | messageDeletedHandler | Removes deleted messages from memory |
CHANNEL_CLEARED | channelClearedHandler | Clears all messages from a channel |
POST_GENERATED | postGeneratedHandler | Creates social media posts |
WORLD_JOINED | handleServerSync | Syncs server/world data |
ENTITY_JOINED | syncSingleUser | Syncs individual user data |
Actions
Actions define what an agent can do in response to messages:
Core Actions
-
REPLY (
reply.ts
)- Default response action
- Generates contextual text responses
- Can be used alone or chained with other actions
-
IGNORE (
ignore.ts
)- Explicitly ignores a message
- Saves the ignore decision to memory
- Used when agent decides not to respond
-
NONE (
none.ts
)- No-op action
- Used as placeholder or default
Room Management Actions
-
FOLLOW_ROOM (
followRoom.ts
)- Subscribes agent to room updates
- Enables notifications for room activity
-
UNFOLLOW_ROOM (
unfollowRoom.ts
)- Unsubscribes from room updates
- Stops notifications
-
MUTE_ROOM (
muteRoom.ts
)- Temporarily disables responses in a room
- Agent still processes messages but doesn’t respond
-
UNMUTE_ROOM (
unmuteRoom.ts
)- Re-enables responses in a muted room
Advanced Actions
-
SEND_MESSAGE (
sendMessage.ts
)- Sends messages to specific rooms
- Can target different channels
-
UPDATE_ENTITY (
updateEntity.ts
)- Updates entity information in the database
- Modifies user profiles, metadata
-
CHOICE (
choice.ts
)- Presents multiple choice options
- Used for interactive decision making
-
UPDATE_ROLE (
roles.ts
)- Manages user roles and permissions
- Updates access levels
-
UPDATE_SETTINGS (
settings.ts
)- Modifies agent or room settings
- Configures behavior parameters
-
GENERATE_IMAGE (
imageGeneration.ts
)- Creates images using AI models
- Attaches generated images to responses
Providers
Providers supply contextual information to the agent during response generation:
Core Providers
-
RECENT_MESSAGES (
recentMessages.ts
) -
TIME (
time.ts
)- Current date and time
- Timezone information
- Temporal context
-
CHARACTER (
character.ts
)- Agent’s personality traits
- Background information
- Behavioral guidelines
-
ENTITIES (
entities.ts
)- Information about users in the room
- Entity relationships
- User metadata
-
RELATIONSHIPS (
relationships.ts
)- Social graph data
- Interaction history
- Relationship tags
-
WORLD (
world.ts
)- Environment context
- Server/world information
- Room details
-
ANXIETY (
anxiety.ts
)- Agent’s emotional state
- Stress levels
- Mood indicators
-
ATTACHMENTS (
attachments.ts
)- Media content analysis
- Image descriptions
- Document summaries
-
CAPABILITIES (
capabilities.ts
)- Available actions
- Service capabilities
- Feature flags
-
FACTS (
facts.ts
)- Stored knowledge
- Learned information
- Contextual facts
Evaluators
Evaluators perform post-interaction cognitive processing:
REFLECTION Evaluator (reflection.ts
)
The reflection evaluator:
- Analyzes conversation quality
- Extracts new facts
- Identifies relationships
- Updates knowledge base
Services
TaskService (task.ts
)
Manages scheduled and background tasks:
Task features:
- Repeating tasks: Execute at intervals
- One-time tasks: Execute once and delete
- Immediate tasks: Execute on creation
- Validated tasks: Conditional execution
Detailed Component Documentation
Message Handler Deep Dive
1. Attachment Processing
2. Should Bypass Logic
3. Response ID Management
Action Handler Pattern
All actions follow this structure:
Provider Pattern
Providers follow this structure:
Configuration
Environment Variables
Character Templates
Configure custom templates:
Template Customization
Understanding Templates
Templates are the core prompts that control how your agent thinks and responds. The plugin-bootstrap provides default templates, but you can customize them through your character configuration to create unique agent behaviors.
Available Templates
- shouldRespondTemplate - Controls when the agent decides to respond
- messageHandlerTemplate - Governs how the agent generates responses and selects actions
- reflectionTemplate - Manages post-interaction analysis
- postCreationTemplate - Handles social media post generation
How Templates Work
Templates use a mustache-style syntax with placeholders:
{{agentName}}
- The agent’s name{{providers}}
- Injected provider context{{actionNames}}
- Available actions{{recentMessages}}
- Conversation history
Customizing Templates
You can override any template in your character configuration:
Template Processing Flow
- Template Selection: The system selects the appropriate template based on the current operation
- Variable Injection: Placeholders are replaced with actual values
- Provider Integration: Provider data is formatted and injected
- LLM Processing: The completed prompt is sent to the language model
- Response Parsing: The XML/JSON response is parsed and validated
Advanced Template Techniques
Conditional Logic
Custom Provider Integration
Understanding the Callback Mechanism
What is the Callback?
The callback is a function passed to every action handler that sends the response back to the user. When you call the callback, you’re telling the system “here’s what to send back”.
Callback Flow
Important Callback Concepts
- Calling callback = Sending a message: When you invoke
callback()
, the message is sent to the user - Multiple callbacks = Multiple messages: You can call callback multiple times to send multiple messages
- No callback = No response: If you don’t call callback, no message is sent
- Async operation: Always await the callback for proper error handling
Callback Examples
Simple Response
Response with Attachments
Multi-Message Response
Conditional Response
Callback Best Practices
- Always call callback: Even for errors, call callback to inform the user
- Be descriptive: Include clear text explaining what happened
- Use appropriate actions: Tag responses with the correct action names
- Include thought: Help with debugging by including agent reasoning
- Handle errors gracefully: Provide user-friendly error messages
Integration Guide
1. Basic Integration
2. Custom Event Handlers
3. Extending Actions
Examples
Example 1: Basic Message Flow
Example 2: Multi-Action Response
Example 3: Task Scheduling
Best Practices
- Always check message validity before processing
- Use providers to gather context instead of direct database queries
- Chain actions for complex behaviors
- Implement proper error handling in custom components
- Respect rate limits and response timeouts
- Test with different room types and message formats
- Monitor reflection outputs for agent learning
Troubleshooting
Common Issues
-
Agent not responding
- Check room type and bypass settings
- Verify agent isn’t muted
- Check shouldRespond logic
-
Duplicate responses
- Ensure response ID tracking is working
- Check for multiple handler registrations
-
Missing context
- Verify providers are registered
- Check state composition
-
Action failures
- Validate action requirements
- Check handler errors
- Verify callback execution
Summary
The @elizaos/plugin-bootstrap
package is the heart of ElizaOS’s message processing system. It provides a complete framework for:
- Receiving and processing messages from any platform
- Making intelligent response decisions
- Generating contextual responses
- Executing complex action chains
- Learning from interactions
- Managing background tasks
Understanding this plugin is essential for developing effective ElizaOS agents and extending the platform’s capabilities.