The Consumer Service is the final delivery layer for notifications, providing a Telegram bot interface for user interactions and consuming notifications from RabbitMQ for delivery to users.
- Notification Delivery: Receive and deliver notifications to Telegram users
- User Interface: Telegram bot for managing DAO subscription preferences
- Session Management: Handle user interactions and maintain state
- Subscription Management: Allow users to subscribe/unsubscribe from DAO notifications
- Bot Interactions: Users interact with Telegram bot to manage preferences
- Message Consumption: Consume notifications from
consumer-queuevia RabbitMQ - Notification Delivery: Send notifications to subscribed Telegram users
- Preference Management: Sync user preferences with Subscription Server
src/
├── app.ts # Main application and service orchestration
├── index.ts # Service entry point
├── messages.ts # Bot message templates and responses
├── config/
│ ├── env.ts # Environment configuration with Zod
│ └── knownCommands.ts # Bot command definitions
└── services/
├── telegram-bot.service.ts # Telegram bot implementation
├── rabbitmq-notification-consumer.service.ts # RabbitMQ message consumer
├── dao.service.ts # DAO preference management
└── subscription-api.service.ts # Subscription Server API client
/start- Initialize bot and show welcome message/daos- Manage DAO notification preferences/learn_more- Learn about Anticapture platform
- Persistent Keyboard: Always-available buttons ("🌐 DAOs", "💡 Learn More")
- Inline Keyboards: Dynamic DAO selection with checkboxes
- Session State: Temporary selections preserved during interaction
- Emoji Support: Visual indicators for different DAOs (🦄 UNI, 🔷 ENS)
| Variable | Required | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN |
✅ | Telegram bot authentication token |
ANTICAPTURE_GRAPHQL_ENDPOINT |
✅ | GraphQL API endpoint for DAO data |
SUBSCRIPTION_SERVER_URL |
✅ | Subscription management API URL |
RABBITMQ_URL |
✅ | RabbitMQ connection string |
TELEGRAM_BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
ANTICAPTURE_GRAPHQL_ENDPOINT=https://api.anticapture.xyz/graphql
SUBSCRIPTION_SERVER_URL=http://subscription-server:3001
RABBITMQ_URL=amqp://user:pass@rabbitmq:5672# Install dependencies
pnpm install
pnpm build
# Set environment variables
cp example.env .env
# Edit .env with your configuration
# Run in development mode
pnpm devConsumes notifications from consumer-queue:
// Expected message structure
{
type: 'NOTIFICATION_EVENT',
payload: {
userId: string,
channelUserId: number,
message: string
}
}// Example notification
"🗳️ New governance proposal in UNI: 'Uniswap Protocol Governance'"# Run all tests
pnpm test
# Run specific test
pnpm test telegram-bot.service.test.ts