A production-ready Flask webhook processor that receives GitHub organization events, validates HMAC signatures, processes them through Letta AI agents, and delivers intelligent Discord notifications.
π’ Repository Status: This repository is now public and open for contributions!
Full GitHub β Letta β Discord integration is operational and production-ready!
- π HMAC-SHA256 Signature Verification - Secure webhook authentication
- π‘ GitHub Event Processing - Issues, PRs, pushes, releases, comments, and more
- π€ Letta AI Integration - Sends events to Mouse agent for intelligent processing
- π¬ Discord Messaging - Self-contained Discord tool with zero dependencies
- β±οΈ Event Buffering - 2-second delays prevent overwhelming AI agents
- π Health Monitoring - Health check and statistics endpoints
- π Auto-Recovery - Cron-based auto-restart system
- π Structured Logging - JSON-formatted logs with full context
- π§ͺ Comprehensive Testing - Real GitHub event testing completed
- π Production Management - Complete deployment and management scripts
- π Full Documentation - Comprehensive guides and API references
GitHub Events β Webhook Processor β Letta Agent (Mouse) β Discord Channel
β β β β
HMAC Verify Event Buffer AI Processing Self-Contained
Event Parse 2s Delay Agent Targeting HTTP Client
git clone https://github.com/AnimusUNO/animus-discord.git
cd animus-discord
python3 -m venv venv
source venv/bin/activate # Linux/Mac
# .\venv\Scripts\Activate.ps1 # Windows
pip install -r requirements.txt# Copy example configuration
cp config.env.example .env
# Edit .env file with your settings
# WEBHOOK_SECRET=your_github_webhook_secret
# LETTA_API_KEY=your_letta_api_key
# DISCORD_BOT_TOKEN=your_discord_bot_token
# DISCORD_CHANNEL_ID=your_discord_channel_id# Production mode (recommended)
./manage-webhook.sh start
# Development mode
python webhook_processor.py# Check health
curl http://localhost:5000/health
# Check statistics
curl http://localhost:5000/stats
# View logs
./manage-webhook.sh logsMain webhook endpoint for receiving GitHub events.
Headers Required:
X-Hub-Signature-256: HMAC-SHA256 signatureX-GitHub-Event: Event type (issues, push, pull_request, etc.)X-GitHub-Delivery: Unique delivery IDContent-Type: application/json
Response:
{
"status": "processed",
"event_id": "delivery-id",
"processed_at": "2025-10-09T20:44:05Z",
"event_count": 1
}Health check endpoint.
Response:
{
"status": "healthy",
"uptime_seconds": 3600,
"events_processed": 42,
"timestamp": "2025-10-09T20:44:05Z"
}Statistics endpoint.
Response:
{
"uptime_seconds": 3600,
"events_processed": 42,
"start_time": "2025-10-09T19:44:05Z",
"webhook_secret_configured": true,
"debug_mode": false
}- Issues: opened, closed, assigned, labeled, etc.
- Pull Requests: opened, closed, merged, reviewed, etc.
- Push: code commits, branch updates, tags
- Release: published, unpublished
- Repository: created, deleted, archived, renamed
- Team: member added/removed, permissions changed
- Organization: member added/removed, billing changes
- Workflow Runs: CI/CD pipeline events
- Deployments: deployment status updates
- Security Events: vulnerability alerts, dependency updates
All events are normalized into a consistent structure:
{
"event_type": "issues",
"delivery_id": "unique-delivery-id",
"timestamp": "2025-10-09T20:44:05Z",
"action": "opened",
"repository": {
"id": 111222333,
"name": "repo-name",
"full_name": "org/repo-name",
"url": "https://github.com/org/repo-name",
"private": false,
"default_branch": "main"
},
"sender": {
"id": 987654321,
"login": "username",
"name": "User Name",
"email": "user@example.com",
"avatar_url": "https://avatars.githubusercontent.com/u/987654321"
},
"organization": {
"id": 444555666,
"login": "org-name",
"name": "Organization Name",
"url": "https://github.com/org-name"
},
"issue": {
"issue_id": 123456789,
"number": 42,
"title": "Issue Title",
"body": "Issue description",
"state": "open",
"labels": ["bug", "priority-high"],
"assignees": ["username"],
"url": "https://github.com/org/repo/issues/42"
}
}Events are filtered based on configurable rules:
- Parse Errors: Automatically skipped
- Test Repositories: Skipped (repositories with "test" in name)
- Custom Rules: Extensible filtering system
All webhook requests are verified using HMAC-SHA256 signatures:
def verify_signature(payload_body: bytes, signature_header: str) -> bool:
sha_name, signature = signature_header.split('=')
expected = hmac.new(
WEBHOOK_SECRET.encode(),
payload_body,
hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected, signature)WEBHOOK_SECRET: GitHub webhook secret (required)FLASK_SECRET_KEY: Flask secret key (required)PORT: Server port (default: 5000)DEBUG: Debug mode (default: False)LOG_LEVEL: Logging level (default: INFO)
# Run all tests
python -m pytest test_webhook_processor.py -v
# Run specific test categories
python -m pytest test_webhook_processor.py::TestWebhookProcessor -v
python -m pytest test_webhook_processor.py::TestWebhookEndpoints -v
python -m pytest test_webhook_processor.py::TestEventParsing -v# Test with running server
python start_webhook.py &
python test_webhook_cli.py --test-endpoint-
Start webhook processor:
python start_webhook.py
-
Update GitHub webhook URL:
gh api --method PATCH /orgs/AnimusUNO/hooks/574364342 \ -f config='{"url":"http://localhost:5000/webhook","content_type":"json","secret":"animus_webhook_secret_2024"}' -
Trigger test events:
- Make commits to
AnimusUNO/animus-discord - Create issues in the repository
- Create pull requests
- Make commits to
-
Monitor logs:
# Check webhook processor logs # Verify events are received and processed
animus-discord/
βββ webhook_processor.py # Main Flask application with Letta integration
βββ letta_integration.py # Letta AI client integration
βββ letta_discord_tool.py # Self-contained Discord tool
βββ manage-webhook.sh # Production webhook management script
βββ manage-cron.sh # Cron job management for auto-recovery
βββ launch-webhook.sh # Webhook startup script
βββ requirements.txt # Python dependencies
βββ requirements-dev.txt # Development dependencies
βββ config.env.example # Environment configuration template
βββ docs/ # Complete documentation
β βββ discord-bot-setup.md # Discord bot configuration guide
β βββ discord-tool.md # Discord tool documentation
β βββ letta-api-reference.md # Letta API reference
β βββ letta_tool_compatibility_notes.md
β βββ production-deployment.md # Production deployment guide
β βββ project-plan.md # Original project plan
βββ scripts/ # Setup utilities
β βββ setup-webhook.sh # GitHub webhook setup
β βββ setup-webhook.ps1 # Windows version
βββ test_webhook_processor.py # Unit tests
βββ test_webhook_cli.py # CLI testing tool
βββ LAUNCH_SCRIPTS.md # Management script documentation
βββ LICENSE # AGPLv3 license for code
βββ LICENSE-CC-BY-SA # CC-BY-SA license for documentation
βββ CONTRIBUTING.md # Contribution guidelines
| Variable | Required | Description |
|---|---|---|
WEBHOOK_SECRET |
β | GitHub webhook secret for HMAC verification |
LETTA_API_KEY |
β | Letta API key for agent communication |
DISCORD_BOT_TOKEN |
β | Discord bot token for messaging |
DISCORD_CHANNEL_ID |
β | Discord channel ID for notifications |
FLASK_SECRET_KEY |
β | Flask secret key for sessions |
PORT |
β | Server port (default: 5000) |
DEBUG |
β | Debug mode (default: False) |
LOG_LEVEL |
β | Logging level (default: INFO) |
-
Create Organization Webhook:
./scripts/setup-webhook.sh AnimusUNO https://your-domain.com/webhook your_secret
-
Configure Events: Select all events (
["*"]) for comprehensive monitoring -
Verify Setup:
gh api /orgs/AnimusUNO/hooks
The system sends GitHub events to the Mouse agent (agent-c2fef691-44d3-4e86-9dbb-a6a681355a8b) which:
- Processes events using AI reasoning
- Formats messages for Discord
- Sends notifications via self-contained Discord tool
- Handles rate limiting with 2-second buffering
The letta_discord_tool.py provides a self-contained Discord messaging function:
- β Zero external dependencies - Uses only Python built-ins
- β Letta-compatible - Proper JSON schema and function signature
- β Agent-specific - Targets Animus agent explicitly
- β Production-ready - Comprehensive error handling
# Start webhook
./manage-webhook.sh start
# Stop webhook
./manage-webhook.sh stop
# Restart webhook
./manage-webhook.sh restart
# Check status
./manage-webhook.sh status
# View logs
./manage-webhook.sh logs
# Health check
./manage-webhook.sh health
# Statistics
./manage-webhook.sh stats# Install cron job for auto-restart
./manage-cron.sh install
# Check cron status
./manage-cron.sh status
# Remove cron job
./manage-cron.sh remove# Create test issue
gh issue create --title "Test Issue" --body "Testing webhook integration"
# Add comment
gh issue comment 1 --body "Test comment"
# Close issue
gh issue close 1# Check webhook health
curl http://localhost:5000/health
# Check statistics
curl http://localhost:5000/stats
# Monitor logs
./manage-webhook.sh logs# Clone repository
git clone https://github.com/AnimusUNO/animus-discord.git
cd animus-discord
# Setup virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Configure environment
cp config.env.example .env
# Edit .env with production values
# Start webhook
./manage-webhook.sh start
# Setup auto-recovery
./manage-cron.sh install# Update webhook URL
gh api --method PATCH /orgs/AnimusUNO/hooks/574364342 \
--field config[url]="https://your-domain.com/webhook" \
--field config[secret]="your-production-secret"- Webhook ID: 574364342
- Organization: AnimusUNO
- Events: All events (
["*"]) - Status: β Active and processing events
- Agent: Mouse (Mini model 4.1)
- Buffer: 2-second delays active
- Endpoint:
GET /health - Response: JSON with status, uptime, event count
- Use Case: Load balancer health checks
- Endpoint:
GET /stats - Response: Detailed statistics
- Use Case: Monitoring dashboards
- Format: Structured JSON logs
- Levels: DEBUG, INFO, WARNING, ERROR
- Context: Event details, processing results
- Discord Bot Setup - Complete Discord bot configuration guide
- Discord Tool - Self-contained Discord tool documentation
- Letta API Reference - Letta integration API reference
- Letta Tool Compatibility - Letta integration requirements
- Production Deployment - Complete production deployment guide
- Management Scripts - Management script documentation
- Project Plan - Original project planning document
This project successfully delivers a complete end-to-end GitHub to Discord integration:
β
Phase 1: GitHub Webhook Processor - Complete
β
Phase 2: Letta AI Integration - Complete
β
Phase 3: Discord Messaging Tool - Complete
β
Production Management: Auto-recovery and monitoring - Complete
β
Documentation: Comprehensive guides and references - Complete
While the core project is complete, potential enhancements could include:
- Enhanced Event Filtering - Advanced filtering rules
- Multiple Agent Support - Support for multiple Letta agents
- Metrics Integration - Prometheus/StatsD integration
- Alerting System - Error notification system
- Web Dashboard - Real-time monitoring interface
-
Signature Verification Failed:
- Check
WEBHOOK_SECRETmatches GitHub webhook secret - Verify webhook URL is correct
- Check
-
Events Not Processing:
- Check webhook is active in GitHub
- Verify webhook URL is accessible
- Check logs for errors
-
High Memory Usage:
- Check for memory leaks in event processing
- Monitor event queue size
Enable debug mode for detailed logging:
export DEBUG="True"
python start_webhook.pyWe welcome contributions to the Discord Animus Agent! Since this repository is now public, we encourage community participation.
π For detailed contribution guidelines, see CONTRIBUTING.md
- Fork the repository on GitHub
- Clone your fork and set up the development environment
- Create a feature branch and make your changes
- Run tests and ensure everything passes
- Create a Pull Request with a clear description
While the core project is complete, contributions are welcome for:
- Enhanced Features: Advanced filtering, multiple agent support
- Testing: Additional test coverage and edge cases
- Documentation: Improvements and additional examples
- Performance: Optimization and monitoring enhancements
- Security: Enhanced security features and audits
- Bug Fixes: Issue resolution and improvements
This project uses dual licensing:
- Source Code: Licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details
- Documentation & Media: Licensed under Creative Commons Attribution-ShareAlike 4.0 International - see the LICENSE-CC-BY-SA file for details
- Code: AGPLv3 ensures that any modifications or network services using this code must also be open source
- Documentation: CC-BY-SA allows sharing and adaptation of documentation with proper attribution