A monorepo containing bots for Telegram, X/Twitter, and Discord that answer questions about the Starknet ecosystem using LangGraph and MCP (Model Context Protocol).
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Bot Platforms β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β Telegram β β Twitter β β Discord β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
β β β β β
β βββββββββββββββββΌββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββ β
β β Queue Manager β β
β β (BullMQ) β β
β ββββββββββ¬ββββββββ β
β β β
β βΌ β
β ββββββββββββββββββ β
β β LangGraph Agentβ β
β β + MCP Adapter β β
β ββββββββββββββββββ β
β β
β βΌ β
β ββββββββββββββββββ β
β β MCP Server β β
β β (Your Tools) β β
β ββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ask-starknet-bot/
βββ packages/
β βββ shared/ # Shared agent, queue, and utilities
β β βββ src/
β β β βββ agent.ts # LangGraph agent with MCP
β β β βββ queue.ts # BullMQ queue manager
β β β βββ types.ts # Shared types
β β β βββ logger.ts # Logging utilities
β β βββ package.json
β β
β βββ telegram-bot/ # Telegram bot (Complete)
β β βββ src/
β β β βββ index.ts # Bot implementation
β β βββ Dockerfile
β β βββ package.json
β β
β βββ twitter-bot/ # X/Twitter bot (Complete)
β β βββ src/
β β β βββ index.ts # Bot implementation
β β βββ Dockerfile
β β βββ package.json
β β
β βββ discord-bot/ # Discord bot (Architecture only)
β βββ src/
β β βββ commands/ # Slash commands (TODO)
β β βββ events/ # Event handlers (TODO)
β β βββ utils/ # Utilities (TODO)
β βββ Dockerfile
β βββ package.json
β
βββ docker-compose.yml # Orchestration for all services
βββ pnpm-workspace.yaml # pnpm workspace configuration
βββ package.json # Root package with shared scripts
βββ tsconfig.json # Shared TypeScript configuration
βββ env.example # Environment variables template
βββ README.md # This file
- Node.js >= 20.0.0
- pnpm >= 8.0.0
- Docker & Docker Compose (for deployment)
- Redis (if running without Docker)
- Clone the repository
git clone <your-repo-url>
cd ask-starknet-bot- Install dependencies
pnpm install- Configure environment variables
cp env.example .env
# Edit .env with your credentials- Build all packages
pnpm buildRun all bots in development mode:
pnpm devRun individual bots:
pnpm telegram:dev
pnpm twitter:dev
pnpm discord:dev- Configure environment
cp env.example .env
# Edit .env with production credentials- Deploy all services
docker-compose up -d- Deploy specific services
# Only Telegram and Redis
docker-compose up -d redis telegram-bot
# Only Twitter and Redis
docker-compose up -d redis twitter-bot- View logs
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f telegram-bot- Stop services
docker-compose downGet your bot token from @BotFather:
- Send
/newbotto BotFather - Follow instructions to create your bot
- Copy the token to
TELEGRAM_BOT_TOKENin.env
Features:
- Responds to direct messages
- Responds to mentions in groups
/start,/help,/statuscommands- Queue-based processing
Usage:
- Direct message: Just send a question
- In groups: Mention the bot
@your_bot_name what is Starknet?
Get your credentials from Twitter Developer Portal:
- Create an App with Read and Write permissions
- Generate API Key, API Secret, Access Token, and Access Secret
- Add credentials to
.env
Features:
- Monitors mentions of your username (e.g.,
@ask_starknet) - Automatic replies with threading for long responses
- Rate limiting and duplicate detection
- Configurable polling interval
Usage:
Users mention your bot: @ask_starknet what's happening with Starknet?
Get your bot token from Discord Developer Portal:
- Create a new Application
- Create a bot and copy the token
- Enable Message Content Intent
- Add token to
.env
Features (Architecture Provided):
- Slash commands:
/ask,/status,/help - Optional mention support
- Embed-based responses
- Queue integration
Status: Architecture and structure provided. Implementation TODO.
Create a .env file based on env.example:
# Required for each bot you want to run
TELEGRAM_BOT_TOKEN=your_token
TWITTER_API_KEY=your_key
TWITTER_API_SECRET=your_secret
TWITTER_ACCESS_TOKEN=your_token
TWITTER_ACCESS_SECRET=your_secret
DISCORD_TOKEN=your_token
DISCORD_CLIENT_ID=your_id
# Redis (for queue)
REDIS_HOST=localhost
REDIS_PORT=6379
# MCP Server Configuration
MCP_COMMAND=npx
MCP_ARGS=-y,@your/mcp-serverThe bots use a centralized LangGraph agent that connects to an MCP (Model Context Protocol) server. Configure your MCP server:
# Example: Using a built-in MCP server
MCP_COMMAND=npx
MCP_ARGS=-y,@modelcontextprotocol/server-everything
# Example: Using a custom MCP server
MCP_COMMAND=node
MCP_ARGS=./your-mcp-server.js
# With environment variables
MCP_ENV={"API_KEY":"your_key","ENV":"production"}The agent uses @langchain/mcp-adapters to communicate with the MCP server.
Core package with:
- LangGraph Agent: Processes queries using MCP integration
- Queue Manager: BullMQ-based queue for concurrent request handling
- Types: Shared TypeScript types and Zod schemas
- Logger: Structured logging with Pino
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Build shared package only
pnpm shared:build
# Run all bots in development
pnpm dev
# Run individual bots
pnpm telegram:dev
pnpm twitter:dev
pnpm discord:dev
# Type checking
pnpm type-check
# Clean build artifacts
pnpm cleanThe monorepo includes a complete Docker Compose setup:
Services:
redis: Queue backendtelegram-bot: Telegram bottwitter-bot: Twitter/X botdiscord-bot: Discord bot
Features:
- Multi-stage builds for optimized images
- Health checks for Redis
- Automatic restarts
- Log rotation
- Shared network
- Persistent Redis data
Deployment:
# Full stack
docker-compose up -d
# Scale services (if needed)
docker-compose up -d --scale telegram-bot=2
# Update and rebuild
docker-compose up -d --build
# Monitor
docker-compose logs -f
# Stop
docker-compose downAll bots use a centralized queue system (BullMQ + Redis) for:
- Concurrent Processing: Handle multiple requests simultaneously
- Rate Limiting: Control processing speed
- Retry Logic: Automatic retries with exponential backoff
- Job Tracking: Monitor job status and metrics
- Error Handling: Graceful error recovery
Queue Metrics:
Each bot provides status information:
- Telegram:
/statuscommand - Twitter: Check logs
- Discord:
/statuscommand (when implemented)
# View all logs
docker-compose logs -f
# Specific service
docker-compose logs -f telegram-bot
# Last 100 lines
docker-compose logs --tail=100 telegram-botSet via LOG_LEVEL environment variable:
debug: Detailed debugging informationinfo: General information (default)warn: Warning messageserror: Error messages only
In production (NODE_ENV=production), logs are in JSON format for easier parsing and aggregation.
- Check environment variables are set correctly
- Verify Redis is running:
docker-compose ps - Check logs:
docker-compose logs -f <service-name>
- Verify Redis connection
- Check worker is started (logs should show "Worker started")
- Check queue metrics
- Verify MCP_COMMAND and MCP_ARGS are correct
- Check if MCP server is accessible
- Review agent logs for connection errors
- Reduce TWITTER_POLL_INTERVAL
- Monitor Twitter API rate limits
- Check for duplicate processing
Run multiple instances of the same bot:
docker-compose up -d --scale telegram-bot=3Adjust in packages/shared/src/queue.ts:
concurrency: 5, // Process up to 5 jobs concurrentlyFor high load, consider:
- Separate Redis instance
- Redis Cluster
- Increased memory limits
- Never commit
.envfiles - Use environment-specific credentials
- Rotate API keys regularly
- Use Redis password in production
- Implement rate limiting per user
- Sanitize user inputs
- Review MCP server security
- Follow existing code structure
- Use TypeScript strict mode
- Write meaningful commit messages
- Test before committing
- Update documentation
MIT
- Telegram Bot API
- Twitter API v2
- Discord.js Guide
- LangGraph Documentation
- MCP Protocol
- BullMQ Documentation
- Start Small: Deploy one bot at a time
- Monitor Logs: Keep an eye on logs during initial deployment
- Test MCP: Verify your MCP server works before deploying
- Set Limits: Configure appropriate rate limits and timeouts
- Backup Data: Regularly backup Redis data if needed
- Health Checks: Monitor bot health and queue metrics
For issues and questions:
- Check bot-specific READMEs
- Review logs for error messages
- Verify configuration
- Check API credentials and permissions
Built with β€οΈ for the Starknet community