Skip to main content

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:
  1. Compose state with relevant providers
  2. Generate response using LLM
  3. Parse XML response format
  4. Execute actions
  5. Send response via callback

Core Components

Event Handlers

Event handlers process different types of events in the system:

Actions

Actions define what an agent can do in response to messages:

Core Actions

  1. REPLY (reply.ts)
    • Default response action
    • Generates contextual text responses
    • Can be used alone or chained with other actions
  2. IGNORE (ignore.ts)
    • Explicitly ignores a message
    • Saves the ignore decision to memory
    • Used when agent decides not to respond
  3. NONE (none.ts)
    • No-op action
    • Used as placeholder or default

Room Management Actions

  1. FOLLOW_ROOM (followRoom.ts)
    • Subscribes agent to room updates
    • Enables notifications for room activity
  2. UNFOLLOW_ROOM (unfollowRoom.ts)
    • Unsubscribes from room updates
    • Stops notifications
  3. MUTE_ROOM (muteRoom.ts)
    • Temporarily disables responses in a room
    • Agent still processes messages but doesn’t respond
  4. UNMUTE_ROOM (unmuteRoom.ts)
    • Re-enables responses in a muted room

Advanced Actions

  1. SEND_MESSAGE (sendMessage.ts)
    • Sends messages to specific rooms
    • Can target different channels
  2. UPDATE_CONTACT (updateEntity.ts)
    • Updates contact/entity information in the database
    • Modifies user profiles, metadata
  3. CHOOSE_OPTION (choice.ts)
    • Presents multiple choice options
    • Used for interactive decision making
  4. UPDATE_ROLE (roles.ts)
    • Manages user roles and permissions
    • Updates access levels
  5. UPDATE_SETTINGS (settings.ts)
    • Modifies agent or room settings
    • Configures behavior parameters
  6. 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

  1. RECENT_MESSAGES (recentMessages.ts)
  2. TIME (time.ts)
    • Current date and time
    • Timezone information
    • Temporal context
  3. CHARACTER (character.ts)
    • Agent’s personality traits
    • Background information
    • Behavioral guidelines
  4. ENTITIES (entities.ts)
    • Information about users in the room
    • Entity relationships
    • User metadata
  5. RELATIONSHIPS (relationships.ts)
    • Social graph data
    • Interaction history
    • Relationship tags
  6. WORLD (world.ts)
    • Environment context
    • Server/world information
    • Room details
  7. ANXIETY (anxiety.ts)
    • Agent’s emotional state
    • Stress levels
    • Mood indicators
  8. ATTACHMENTS (attachments.ts)
    • Media content analysis
    • Image descriptions
    • Document summaries
  9. CAPABILITIES (capabilities.ts)
    • Available actions
    • Service capabilities
    • Feature flags
  10. ACTIONS (actions.ts)
    • Available action definitions
    • Action metadata
    • Action examples
  11. PROVIDERS (providers.ts)
    • List of available providers
    • Provider metadata
    • Provider ordering
  12. EVALUATORS (evaluators.ts)
    • Available evaluator definitions
    • Evaluator metadata
    • Evaluation examples
  13. SETTINGS (settings.ts)
    • Agent configuration
    • Runtime settings
    • Plugin settings
  14. ROLES (roles.ts)
    • User role information
    • Permission levels
    • Role assignments
  15. CHOICE (choice.ts)
    • Pending choice options
    • User selection context
    • Choice metadata
  16. ACTION_STATE (actionState.ts)
    • Current action execution state
    • Previous action results
    • Action chain context
  17. FACTS (facts.ts)
    • Stored knowledge and learned facts
    • Contextual information
    • Agent memory facts

Evaluators

Evaluators perform post-interaction cognitive processing:

REFLECTION Evaluator (reflection.ts)

The reflection evaluator:
  1. Analyzes conversation quality
  2. Extracts new facts
  3. Identifies relationships
  4. 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

  1. shouldRespondTemplate - Controls when the agent decides to respond
  2. messageHandlerTemplate - Governs how the agent generates responses and selects actions
  3. reflectionTemplate - Manages post-interaction analysis
  4. 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

  1. Template Selection: The system selects the appropriate template based on the current operation
  2. Variable Injection: Placeholders are replaced with actual values
  3. Provider Integration: Provider data is formatted and injected
  4. LLM Processing: The completed prompt is sent to the language model
  5. 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

  1. Calling callback = Sending a message: When you invoke callback(), the message is sent to the user
  2. Multiple callbacks = Multiple messages: You can call callback multiple times to send multiple messages
  3. No callback = No response: If you don’t call callback, no message is sent
  4. 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

  1. Always call callback: Even for errors, call callback to inform the user
  2. Be descriptive: Include clear text explaining what happened
  3. Use appropriate actions: Tag responses with the correct action names
  4. Include thought: Help with debugging by including agent reasoning
  5. 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

  1. Always check message validity before processing
  2. Use providers to gather context instead of direct database queries
  3. Chain actions for complex behaviors
  4. Implement proper error handling in custom components
  5. Respect rate limits and response timeouts
  6. Test with different room types and message formats
  7. Monitor reflection outputs for agent learning

Troubleshooting

Common Issues

  1. Agent not responding
    • Check room type and bypass settings
    • Verify agent isn’t muted
    • Check shouldRespond logic
  2. Duplicate responses
    • Ensure response ID tracking is working
    • Check for multiple handler registrations
  3. Missing context
    • Verify providers are registered
    • Check state composition
  4. 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.