A powerful, production-ready Discord bot integrated with Letta AI for intelligent conversations with long-term memory, task scheduling, and image processing capabilities.
- Intelligent conversations with persistent memory
- Context-aware responses across sessions
- Customizable agent personalities
- Streaming responses for real-time interaction
- Automatic message chunking for long responses (Discord 2000 char limit)
- Multi-image support (up to 10 images per message)
- Automatic compression for large files (4MB+ β optimized)
- Security: SSRF protection (Discord CDN only)
- Rate limiting: 1 request per 3 seconds per user
- Supports JPEG, PNG, WebP formats
- Schedule notifications and reminders
- Recurring tasks (daily, hourly, custom intervals)
- One-time or repeating tasks
- User mentions and channel posts
- JSON-based task configuration
- Autonomous agent activity
- Configurable intervals and probability
- Allows agent to reflect and self-organize
- Input validation on all URLs
- Memory leak prevention
- Proper error handling with user-friendly messages
- PM2 support for 24/7 operation
- Rate limiting per user
- Node.js >= 18.0.0
- Discord Bot - Create one here
- Letta API Account - Sign up at letta.com
- Clone the repository
git clone https://github.com/Duzafizzl/Letta-Discord-advanced.git
cd Letta-Discord-advanced- Install dependencies
npm install- Configure environment
# Copy the example env file
cp .env.example .env
# Edit .env with your values
nano .env # or use your preferred editor- Build TypeScript
npm run build- Start the bot
npm start# Discord
DISCORD_TOKEN=your_discord_bot_token
# Letta AI
LETTA_API_KEY=your_letta_api_key
LETTA_AGENT_ID=your_agent_idSee .env.example for all available options including:
- Response modes (mentions, DMs, channels)
- Task scheduler settings
- Heartbeat/timer configuration
- Logging preferences
npm run dev# Install PM2 globally
npm install -g pm2
# Start bot
npm run pm2:start
# View logs
npm run pm2:logs
# Restart bot
npm run pm2:restart
# Auto-start on system boot
pm2 startup
pm2 saveYou can deploy to various cloud platforms:
- Railway - One-click deploy
- Heroku - Free tier available
- DigitalOcean - Droplets starting at $5/month
- AWS/GCP/Azure - Enterprise options
- Any VPS - Self-hosted with PM2
Create scheduled tasks in your designated tasks channel:
{
"task_name": "morning_reminder",
"description": "Daily good morning message",
"schedule": "daily",
"next_run": "2025-10-10T09:00:00",
"action_type": "user_reminder",
"action_target": "USER_ID_HERE",
"action_template": "Good morning! Have a great day! βοΈ",
"one_time": false,
"active": true
}daily- Every day at the specified timehourly- Every hourminutely- Every minute (for testing)every_X_minutes- Custom minute intervalevery_X_hours- Custom hour intervalevery_X_days- Custom day intervalweekly- Every 7 daysmonthly- Every month
The bot checks for due tasks every 60 seconds.
Send images to the bot and it will analyze them using Letta AI's vision capabilities.
- β Up to 10 images per message
- β Automatic compression for large files
- β Security validation (Discord CDN only)
- β Detailed error messages
- β Rate limiting to prevent spam
Simply upload an image and add text:
@BotName What's in this image?
The bot will:
- Download the image(s)
- Compress if needed (>4MB β WebP/JPEG optimized)
- Send to Letta AI for analysis
- Reply with the AI's description
This bot comes with pre-configured Letta tools for Discord interaction. You need to set these up in your Letta agent:
- send_discord_dm - Send direct messages to users
- send_discord_message - Post in Discord channels
- create_scheduled_task - Create new scheduled tasks
- delete_scheduled_task - Remove scheduled tasks
See docs/LETTA_TOOLS.md for detailed tool schemas and setup instructions.
- Letta Tools Setup - Discord tool configurations
- Image Processing - Image handling details
- Contributing - How to contribute
# Check logs
npm run pm2:logs
# Common issues:
# - Missing .env file β cp .env.example .env
# - Invalid Discord token β check Discord Developer Portal
# - Missing dependencies β npm install- Ensure
TASKS_CHANNEL_IDis set in.env - Check channel permissions (bot needs read access)
- View logs:
npm run pm2:logs
- Check if
sharpis installed:npm list sharp - Install system dependencies (Debian/Ubuntu):
sudo apt install libvips-dev - Rebuild Sharp:
npm install sharp --build-from-source
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- Letta AI - For the amazing AI platform
- Discord.js - For the Discord API wrapper
- Sharp - For image processing
Made with β€οΈ for the community
If you find this project helpful, consider giving it a β on GitHub!