Bot Sender (Project: ms_bot_sender)¶
ms_bot_sender is a lightweight Celery worker dedicated to delivering outbound notifications for the Explorer bot and web alerts.
It decouples the high-volume notification producers (site, API, cron jobs) from the actual Telegram/email transport layer.
Responsibilities¶
- Consume
bot_messagetasks from thebot_senderqueue (defined inccdexplorer.celery_app). - Deserialize
MessageResponsepayloads and forward them via: TooterChannel.BOT(Telegram) for chat-based alerts.- Fastmail SMTP (
Tooter.email) for email notifications. - Retry transient failures using Celery’s autoretry logic (configured backoff/jitter with gRPC/connection exceptions).
- Surface failures by raising the exception so Celery marks the task as
FAILUREand records metadata viastore_result_in_mongo.
Message shape¶
{
"service": "telegram" | "email",
"telegram_chat_id": 123456789,
"email_address": "user@example.com",
"message_response": {
"title_telegram": "...",
"message_telegram": "...",
"title_email": "...",
"message_email": "..."
}
}
The upstream producers (Explorer bot, notification scheduler, API) are responsible for populating the MessageResponse.
Deployment¶
- The worker entry point runs
celery_app.worker_mainwith-Q bot_sender --pool=solo, making it safe to run alongside other services without competing for resources. - Environment variables such as
RUN_LOCAL_STRand the Fastmail API token are pulled fromcomponents/env. - The Dockerfile in
projects/ms_bot_sender/installs the baseccdexplorer.ms_bot_senderpackage so this worker can be deployed independently.
Related services¶
ccdexplorer_botproduces notification intents.ms_events_and_impactsand other data services enqueue messages targeted at the bot sender when they detect an event worthy of alerting.***